日期:2014-05-20 浏览次数:20632 次
public class Test {
int x=10;
static int y=20;
public static void main(String[] args){
Test t1=new Test();
Test t2=new Test();
t1.x*=2;
t1.y*=3;
t2.x+=4;
t2.y+=5;
System.out.println(t1.x);
System.out.println(t1.y);
System.out.println(t2.x);
System.out.println(t2.y);
}
}
public class StaticTest {
int x=10;
static int y=20;
public static void main(String[] args){
StaticTest t1=new StaticTest();
StaticTest t2=new StaticTest();
t1.x*=2; //t1.x = 20
t1.y*=3; //y=60
t2.x+=4; //t2.x=14
t2.y+=5; //y=65
System.out.println(t1.x); //20
System.out.println(t1.y); //65
System.out.println(t2.x); //14
System.out.println(t2.y); //65
}
}