JavaSE 面试题: 成员变量与局部变量
JavaSE 面试题 成员变量与局部变量 public class Test { static int s; int i; int j; { int i = 1; i++; j++; s++; } public void test(int j) { j++; i++; s++; } public static void main(String[] args) { Test t1 = new Test(); Test t2 = new Test(); t1.test(10); t1.test(20); t2.test(30); System.out.println(t1.i + ", " + t1.j + ", " + t1.s); System.out.println(t2.i + ", " + t2.j + ", " + t2.s); } } 参考答案 2, 1, 5 1, 1, 5 来源: https://www.cnblogs.com/hglibin/p/11380250.html