If you have already register Login here.
Java identifiers
int score;
Here, score is a variable (an identifier). You cannot use keywords as variable name. Its because keywords have predefined meaning. For example,
int float;
The above code is wrong. Its because float is a keyword and cannot be used as a variable name.
public class Test
{
public static void main(String[] args)
{
int a = 20;
}
}
In the above java code, we have 5 identifiers namely :
There are certain rules for defining a valid java identifier. These rules must be followed, otherwise, we get a compile-time error. These rules are also valid for other languages like C, C++.
score
level
highestScore
number1
convertToString
MyVariable
MYVARIABLE
myvariable
x
i
x1
i1
_myvariable
$myvariable
sum_of_array
easyto123
class
float
1number
highest Score
@pple
My Variable // contains a space
123easyto // Begins with a digit
a+c // plus sign is not an alphanumeric character
variable-2 // hyphen is not an alphanumeric character
sum_&_difference // ampersand is not an alphanumeric character
© 2025 Easy To Learning. All Rights Reserved | Design by Easy To Learning