public class Outer {
private String name = "李四";
private String sex = "男";
//静态类和外部类权限一样
/*外部调用
Outer.Inter inter = new Outer.Inter(); Outer.Inter仅表示包含关系,
如果是成员类应为 Outer.Inter inter = new Outer().Inter();还需要导入调用类的包;
*/
static class Inter{
private String address = "湖南";
public static int age = 18;
public void exhibt(){
Outer outer = new Outer();//静态类中的方法引用外部类需要实例化外部类
System.out.println(outer.name);
System.out.println(address);
System.out.println(inter.age);//引用静态类的静态属性
}
}
}