java 中的标识符到底是什么?

What are identifiers in java exactly?

我不明白 java 标识符的完整定义。例如:

String st = "hello";
if(st.equals("hello") return st;

等号算作标识符吗? 我需要创建一个程序,在其中检测源代码中的标识符并存储它们(如果存在)。但是,如果 java 库方法不算作标识符,那么我就无法只存储已编程的命名变量、方法和 类.

来自快速 Google search:

Identifiers are the names of variables, methods, classes, packages and interfaces. Unlike literals they are not the things themselves, just ways of referring to them. In the HelloWorld program, HelloWorld, String, args, main and println are identifiers.

因此在您的情况下:Stringstequals 都是标识符,因为它们分别是 类、变量和方法的名称。