public class StaticTester {
public int x=1;
public static int y=1;
}
public class StaticTest {
public static void main(String[] args) { StaticTester.y+=1;
StaticTester t1=new StaticTester();
StaticTester t2=new StaticTester();
t1.x+=1;
t1.y+=1;
t2.x+=2;
t2.y+=2;
System.out.println("T1:x="+t1.x+",y="+t1.y);
System.out.println("T2:x="+t2.x+",y="+t2.y);
}}
运行后答案:T1 x=2 ,y=5
T2 x=3,y=3
为什么?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货