0% found this document useful (0 votes)
4 views2 pages

What Are Identifiers in Java

Identifiers in Java are names assigned to various elements such as classes, methods, and variables, similar to how objects in the real world have names. There are specific rules for naming identifiers, including allowed characters, restrictions on reserved words, and case sensitivity. Identifiers cannot start with a digit and while there is no length limit, overly lengthy identifiers are discouraged.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

What Are Identifiers in Java

Identifiers in Java are names assigned to various elements such as classes, methods, and variables, similar to how objects in the real world have names. There are specific rules for naming identifiers, including allowed characters, restrictions on reserved words, and case sensitivity. Identifiers cannot start with a digit and while there is no length limit, overly lengthy identifiers are discouraged.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

What are identifiers in java

What are identifiers?


We have an identifier for everything in the real world around us. If you look
around you can see your phone, table, pen, etc. Everything around us has
a name. These names are nothing but identifiers for objects around us.
These identifiers around us help us identify those things and communicate
better. Similarly in java, we have identifiers that are names given to method
name, variable name, class name

Example :
class​ ​ABC​{
public​ ​static​ ​void​ ​main​(String args[]){
int​ x = ​10​;
}
}

There are 5 identifiers in this program above


Class name - ​ABC
Method name - ​main()
Predefined class name : ​String[]
Argument name : ​args
Integer : ​x

Rules for naming identifiers


1. The only allowed characters in java identifiers are a to z, A to Z, 0 to
9, $, _
2. We can’t use reserved words as identifiers
3. All predefined java class names and interface names can be used as
identifiers

© Faisal Memon
4. Identifiers cannot start with a digit. Total123 is valid, but 123total is
invalid and we will get a compile time error.
5. Java identifiers are case sensitive since java language is case
sensitive programming language
6. There is no length limit for java identifiers, but it is not recommended
to take too lengthy identifiers.

© Faisal Memon

You might also like