- public class Outer {
- public String name = "Outer";
- private class Inner {
- String name = "Inner";
- void showName() {
- System.out.println(name);
- }
- }
- public static void main(String[] args) {
- Outer outer = new Outer();
- Inner inner = outer.new Inner();
- inner.showName();
- System.out.println(inner.name);
- }
- }
复制代码
应该可以了... |