使用static 定义内部类。

使用static  定义的内部类成了外部类,但是用static  声明的内部类不能访问非static声明的外部类的属性
public class Outher1 {
private static String info = "HELLO WORLD";

static class Inner {
public void prinln() {
System.out.println(info);
}
}

public static void main(String[] args) {
new Outher1.Inner().prinln();
}
}

上一篇:一篇文章掌握 Python 中的装饰器


下一篇:Python的闭包