内部类案例(12.16)
作者:互联网
/*
class Outer {
public int num = 10;
class Inner {
public int num = 20;
public void show() {
int num = 30;
System.out.println(?);
System.out.println(??);
System.out.println(???);
}
}
}
在控制分别输出:30,20,10•
*/
class Outer5 {
public int num = 10;
class Inner5 {
public int num = 20;
public void show() {
int num = 30;
System.out.println(num);
System.out.println(this.num);
//Inner5与Outer5不是继承关系,没有super关键字
// System.out.println(super.num);
System.out.println(Outer5.this.num);
System.out.println(new Outer5().num);
}
}
}
public class InnerClassDemo5 {
public static void main(String[] args) {
Outer5.Inner5 oi5 = new Outer5().new Inner5();
oi5.show();
}
}
标签:内部,案例,int,System,12.16,num,println,public,out 来源: https://www.cnblogs.com/shuangjianga/p/15700732.html