1.定义
public class Enclosing { //静态内部类 static class Nexted{} //内部类 class Inner{} }
2.获取内部类和静态内部类
public class Main { public static void main(String[] args) { //获取内部类(外部类对象获取内部类对象) Enclosing.Inner inner = new Enclosing().new Inner(); //获取静态类(类名获取静态类对象) Enclosing.Nexted nexted = new Enclosing.Nexted(); } }