码迷,mamicode.com
首页 > 其他好文 > 详细

static面试总结

时间:2018-11-13 00:02:27      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:str   内部类   int   import   oid   静态代码块   port   bsp   vat   

static用法:

  1. 静态变量;
  2. 静态方法;
  3. 静态代码块;
  4. 静态内部类;
  5. 静态导包。

1、静态变量:

private static int a = 0

2、静态方法:

public static void main( String[] args )
    {

        System.out.println( "Hello World!" );
    }

3、静态代码块:

static{
        System.out.println( "Hello World!" );
    }

4、静态内部类:

static class StaticClass{
        public void test(){
            System.out.println( "Hello World!" );
        }
    }

5、静态导包:

import static java.lang.Math.*;
/**
 * 静态导包
 *
 */
public class App {
    public static void main( String[] args ){
        System.out.println( "Hello World!" + Math.round(66.6));//传统做法
        System.out.println( "Hello World!" + round(66.6));
    }
}

 

static面试总结

标签:str   内部类   int   import   oid   静态代码块   port   bsp   vat   

原文地址:https://www.cnblogs.com/hujinshui/p/9949431.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!