我已经多次遇到这个问题而且我从不费心去了解它为什么会发生并学习"静态"实际意味着什么.我刚刚应用了Eclipse建议并继续进行的更改.
public class Member {
// Global Variables
int iNumVertices;
int iNumEdges;
public static void main(String[] args) {
// do stuff
iNumVertices = 0; // Cannot make a static reference to the non-static field iNumVertices
// do more stuff
} // main end
}
Run Code Online (Sandbox Code Playgroud)
所以eclipse告诉我这样做static int iNumVertices;,我不知道为什么.那究竟什么是"静态",它是如何使用的,使用"静态"的目的是什么,为什么它会给我这个问题呢?