Tag: 非静态的

非静态variables不能从静态上下文中引用

我已经写了这个testing代码: class MyProgram { int count = 0; public static void main(String[] args) { System.out.println(count); } } 但它给出了以下错误: Main.java:6: error: non-static variable count cannot be referenced from a static context System.out.println(count); ^ 我如何让我的方法来识别我的类variables?