62,625
社区成员
发帖
与我相关
我的任务
分享
class Outer {
private int b = 11;
private class Inner {
int a = 10;
public void show() {
System.out.println(b);
}
}
public void show1(){
Inner inner = new Inner();
inner.show();
}
}
public class A {
private static class B1 {}
private class B2 {}
static {
B1 b1 = new B1(); // 创建 B1 对象无需在 A 的实例中
}
{
B2 b2 = new B2(); // 注意必须在 A 的非静态方法中才能创建 B2
}
}