我在查看一些代码时看到了这个:
public class A {
public A(SomeObject obj) {
//Do something
}
//Some stuff
public static class B {
//Some other stuff
}
}
我想知道既然内部类是public
为什么要将其嵌套而不是作为一个单独的类?此外,我能在这里这样做吗:new A.B(SomeObject)
?我觉得这违背了静态类的目的,但我也看到过这种实现方式,所以想知道。
new A.B(SomeObject)
的回答是错误的,这其实很有道理,因为静态类没有构造函数。 - noMAD