public class StaticTest{
private static int x=100;
public static void main(String args[] ){
StaticTest hs1=new StaticTest( );
hs1.x++;
System.out.println("1="+x);
StaticTest hs2=new StaticTest( );
hs2.x++;
System.out.println("2="+x);
hs1=new StaticTest( );
hs1.x++;
System.out.println("3="+x);
StaticTest.x--;
System.out.println("4="+x);
}
}
java里面非静态的变量,不new出来他的类是一定不能用的,但是如果是static的不管new不new出来对象,都能调用