为什么要用两种不同的方式来创建 Inner 类 的实例?

Why two different ways to create instance of Inner classes?

现在我在研究静态内部class,我发现静态内部class和非静态内部class的对象创建方式是不同的。但是我不明白为什么。

对于非静态内部 class:

Outer.Inner inner = new Outer().new Inner();

对于静态内部 class:

Outer.Inner inner = new Outer.Inner();

non-static class 的全部意义在于它链接到外部 class.

的实例

这就是您需要从实例创建它的原因。