Search code examples
javaparsingidentifier

What are identifiers in java exactly?


I don't understand the full definition of a java identifier. 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.


Solution

  • From a quick 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.

    So in your case: String, st, and equals are all identifiers as they are the names of classes, variables, and methods respectively.