static用法:
静态变量;静态方法;静态代码块;静态内部类;静态导包。
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
));
}
}