- class Zi
- {
- int num = 1;
-
- {
- System.out.println("Zi代码块1..."+num);
- int num = 2;
- }
-
- {
- System.out.println("Zi代码块2..."+num);
- num = 3;
- }
-
- {
- System.out.println("Zi代码块3..."+num);
- }
-
- Zi(){}
- }
- class Test
- {
- public static void main(String[] args)
- {
- new Zi();
- }
- }
复制代码 运行结果如下:
求解为何代码
"
Zi代码块2...1 " 为何结果不是 Zi代码块2...2 ? 代码块中 int num = 2; 和 num = 2; 有何区别? |