package 练习;
//关于内部类和外部类之间的小练习
class Outer{
private String msg="Hello,World";
class Inner{
private String msg="你好,世界";
public void fun() {
System.out.println(Outer.this.msg);
}
}
public void fun() {
Inner s=new Inner();cpp
s.fun();
System.out.println(s.msg);
}
}
public class Practise01 {
public static void main(String args[]) {
Outer a=new Outer();
a.fun();
}
}
输出结果是:
image.png
image.png
网友评论