Answer» Identifiers are used to identify items in the Java programming language. A class name, method name, variable name, or label can all be used as identifiers in Java. Rules for defining Java identifiers:-
- A proper Java identifier must follow certain guidelines. If we don’t follow these guidelines, we’ll get a compile-time error. These criteria apply to other languages as well, such as C and C++.
- All alphanumeric characters ([A-Z],[a-z],[0-9]), ‘$’ (dollar symbol), and ‘_’ are the only characters that can be used as identifiers (underscore). For example, “bit@” is not an acceptable Java identifier because it contains the special character ‘@,’.
- Numbers should not be used to begin identifiers ([0-9]). “123geeks,” for example, is not a valid Java identifier.
- Case matters when it comes to Java Identifiers. For example ‘bit’ and ‘BIT’ would be considered as different identifiers in Java.
- The length of the identifier is not limited, however, it is recommended that it be kept to a maximum of 4–15 letters.
- Reserved Words aren’t allowed to be used as identifiers. Because while is a reserved term, “int while = 20;” is an incorrect sentence. In Java, there are 53 reserved terms.
- The length of the identifier is not limited, however, it is recommended that it be kept to a maximum of 4–15 letters.
Reserved words:- Some words are reserved in the Java programming language to indicate the language’s established features. These are known as reserved words. They can be divided into two categories: keywords(50) and literals (3). Functionalities are defined by keywords, and literals are defined by values. Symbol tables use identifiers in the various analysing phases of a compiler architecture (such as lexical, syntactic, and semantic).
|