编译器为什么在这里抱怨?它不允许我在main中创建一个Wrapper
对象。 MyList是一个单独的类。我如何创建它?为什么我不能在main中实例化一个内部类?
public class BinaryTree {
Node root;
class Wrapper {
MyList.Node node;
}
class Node {
Integer value;
Node left;
Node right;
Node(int value) {
this.value = value;
}
}
public static void main() {
MyList list = new MyList();
Wrapper w = new Wrapper();
w.node = list.getHead();
}
}
发布编译器投诉。 – 2013-05-08 04:30:55
-1不发布编译器错误。 – 2013-05-08 04:37:29
http://stackoverflow.com/questions/12690128/how-to-instantiate-non-static-inner-class-within-a-static-method – RAS 2013-05-08 06:49:52