public class test4 { public static void main(String[] args) { test4 a = new test4(); System.out.println(a.i); } public int i = 1; public test4 () { System.out.println(i); i=2; } }
输出结果为:
1
2
Process finished with exit code 0
public class test4 { public static void main(String[] args) { test4 a = new test4(); System.out.println(a.i); } public int i = 1; public test4 () { System.out.println(i); i=2; } }
输出结果为:
1
2
Process finished with exit code 0
转载于:https://www.cnblogs.com/kincolle/p/7237463.html