A variable in java like other programming language are used to store or hold the values that are used in a program.
Before using the variable we have to declare the variable and then assign value to it.
We can also assign data to a variable with its declaration as well as within a method. The simple example to show the use of variable is below:
A constant value in Java is said as a literal representation of it. Literals are represented directly in the code without any computation.
So a constant value assign to a variable without any computation or calculation is know as literals in java. for example:
In above program, we have used following types of literals:
Identifiers can be referred as anything that is used to uniquely identified the variables, methods, classes, packages and interfaces in a program.
Identifiers must have to follow the rule of java for identifiers that are given below:
1) A Java identifier must begin with a letter, underscore, or the dollar sign.
2) A Java identifier consists of letters, digits, the underscore character (_), and the dollar sign ($) ; no other symbols are permitted to form an identifier.
3) Java is case sensitive means uppercase and lowercase letters are considered different.
4) Identifiers can be any length means unlimited .But it is a good code practice to have short and suitable identifers