Everything you need to know about Identifiers in Java

Published on Aug 20,2019 2.6K Views

Everything you need to know about Identifiers in Java

edureka.co

Identifiers in Java is a very important aspect of Programming. They are mainly used for Identification Purposes. Following pointers will be covered in this article,

The name given to a package, interface, class, method or a variable is known as a java identifier. In simpler terms, it can be defined as identification through symbolic names.

Let’s take a look at an example for a better understanding:

 

Sample of Identifiers in Java

public class A
{
    public static void main(String[] args)
    {
        int s = 18;
    }
}

 

In the above code, five identifiers are present as such:

 

Rules for defining Identifiers in Java:

 

Legal Variable Names:


MyVariable
MYVARIABLE
myvariable
x
i
_myvariable
$myvariable
sum_of_numbers
edureka123

 

Invalid Variable Names:


My Variable // contains a white space
456edureka // Begins with a digit
c+d // plus sign is not an alphanumeric character
variable-5 // hyphen is not an alphanumeric character
add_&_sub // ampersand is not an alphanumeric character

 

Reserved words in Java:

To represent certain functionalities, java reserves some words. These words are known as reserved words. They cannot be used as identifiers as they are already used by the java syntax.
Reserved Words can be differentiated into keywords (50) and literals(3). While the functionality is defined by a keyword, the value is defined by a literal.

Identifiers are a necessity as they make the program readable and efficient.

Check out the Java training by Edureka, a trusted online learning company with a network of more than 250,000 satisfied learners spread across the globe. Edureka’s Java J2EE and SOA training and certification course are designed for students and professionals who want to be a Java Developer. The course is designed to give you a head start into Java programming and train you for both core and advanced Java concepts along with various Java frameworks like Hibernate & Spring.

Got a question for us? Please mention it in the comments section of this blog and we will get back to you as soon as possible.

Upcoming Batches For Java Certification Training Course
Course NameDateDetails
Java Certification Training Course

Class Starts on 4th May,2024

4th May

SAT&SUN (Weekend Batch)
View Details
Java Certification Training Course

Class Starts on 25th May,2024

25th May

SAT&SUN (Weekend Batch)
View Details
BROWSE COURSES
REGISTER FOR FREE WEBINAR UiPath Selectors Tutorial