English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
In this tutorial, you will learn about keywords. Reserved words in Java programming. You will also learn about identifiers.
Keywords are predefined reserved words used in Java programming that have special meaning to the compiler. For example:
int score;
Here, int is a keyword. It indicates that the variable score is of integer type (32A signed two's complement binary integer.
You cannot use keywords like int, for, class, etc. as variable names (or identifiers) because they are part of the syntax of the Java programming language. This is the complete list of all keywords in Java programming.
In addition to these keywords, true, false, and null cannot be used as identifiers. This is because they are literals.
An identifier is a name given to variables, classes, methods, and so on.
int score;
Here, score is a variable (identifier). You cannot use keywords as variable names because keywords have predefined meanings. For example,
int float;
The code above is incorrect because float is a keyword and cannot be used as a variable name.
To learn more about variables, please visitJava Variables.
Identifiers cannot be keywords.
Identifiers are case-sensitive.
It can have a sequence of letters and numbers. However, it must start with a letter, $, or \, and the first letter cannot be a number.
By convention, identifiers start with a letter rather than $ or _.
Spaces are not allowed.
Similarly, symbols such as @, #, etc., cannot be used.
The following are some valid identifiers:
Score
Level
highestScore
Number1
convertToString
The following are some invalid identifiers:
Class
Float
1Number
Highest Score
@pple