【发布时间】:2012-11-02 15:38:01
【问题描述】:
可能重复:
Why do I get “non-static variable this cannot be referenced from a static context”?
这里是代码
public class Stack
{
private class Node{
...
}
...
public static void main(String[] args){
Node node = new Node(); // generates a compiling error
}
}
错误提示:
非静态类节点不能从静态上下文中引用
为什么我不应该在 main() 方法中引用 Node 类?
【问题讨论】:
-
“节点”应该不是“堆栈”的内部类。恕我直言...
标签: java inner-classes