Day09局部内部类

103 阅读1分钟
public class outer {
int a = 10;
static int b = 20;
//定义在方法体里面的类叫做局部内部类
public void name() {
	int c = 30;
class inner{
	int d = 40;
//	Static int d = 40;局部内部类也不允许出现静态资源
	public void show() {
		//可使用外部所有资源
		System.out.println(a);
		System.out.println(b);
		System.out.println(c);
	
	}
}
	
	//在方法体中创建内部类资源 然后外部类方法使用方法体就可访问内部类资源
	inner inner = new inner();
	inner.show();
	
}


public void run() {
	name();
}
}