Day07变量的访问原则

143 阅读1分钟
public class Day1 {
	
//	变量访问就近原则
//	相同大括号里面不允许有同名变量
	static int  a = 10;
	
	
	public static void main(String[] args) {
		int a = 20;//方法执行完毕此变量就消失了
		
		System.out.println(a);//20就近原则
	}

	
	public static void show() {
		System.out.println(a);//10  方法中的局部变量不共享给其他方法
	}
	
	
}