Full Stack Web Development Internship Program
- 29k Enrolled Learners
- Weekend/Weekday
- Live Class
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:
public class A { public static void main(String[] args) { int s = 18; } }
In the above code, five identifiers are present as such:
The characters that are allowed for identifiers are limited to all the alphanumeric characters ([A-Z],[a-z],[0-9]), ‘$‘(dollar sign) and ‘_‘ (underscore). For example, “edureka@” is an invalid name as a special character “@” is present in it.
The identifiers should not begin with digits ([0-9]). For example, “123edureka” is invalid.
Identifiers in java are case sensitive.
While there is no such limit on the length of an identifier, programmers are advised to use an appropriate length of 4-15 letters.
It must be noted that Reserved Words should not be used as identifiers. For example, “int while = 18” is invalid in java, as while is a reserved word.
No white space must be given while defining a variable name.
All the variable names are case-sensitive.
MyVariable MYVARIABLE myvariable x i _myvariable $myvariable sum_of_numbers edureka123
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
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.
Course Name | Date | Details |
---|---|---|
Java Course Online | Class Starts on 7th December,2024 7th December SAT&SUN (Weekend Batch) | View Details |
edureka.co