简体   繁体   English

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

[英]What are identifiers in java exactly?

I don't understand the full definition of a java identifier. 我不了解Java标识符的完整定义。 For example in: 例如在:

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

Would equals count as an identifier? 将等于算作标识符吗? I need to create a program in which identifiers are detected in source code and stored if they are. 我需要创建一个程序,其中在源代码中检测到标识符并将标识符存储(如果存在)。 But if the java library methods don't count as identifiers, then there's no way I could store only the programmed named variables, methods, and classes. 但是,如果java库的方法不算作标识符,那么我就无法只存储已编程的命名变量,方法和类。

From a quick Google search : 通过快速的Google搜索

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. 在HelloWorld程序中,HelloWorld,String,args,main和println是标识符。

So in your case: String , st , and equals are all identifiers as they are the names of classes, variables, and methods respectively. 因此,在您的情况下: Stringstequals都是标识符,因为它们分别是类,变量和方法的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM