Lu *_*Yas 0 c++ java global-variables
如何在Java中编写C++的所有这些全局变量?
//Global variables
int charClass;
char lexeme [100];
char nextChar;
int lexLen;
int token;
int nextToken;
extern string word("Apple");
Run Code Online (Sandbox Code Playgroud)
一个类中的公共静态变量怎么样?
public class Globals {
public static int charClass;
public static char[] lexeme = new char[100];
public static char nextChar;
public static int lexLen;
public static int token;
public static int nextToken;
public static String word = "Apple";
}
Run Code Online (Sandbox Code Playgroud)
有几个不同,但主要想法是相似的(至少对于原语).