Part 7 – Reserve words, Key words, Identifiers, Java Comments
July 23, 2020 2 min read

Hello guys, welcome back. In part 6 we discussed about the java literals. If you didn’t still take a look on before articles about java, go and check them. Trust me you will get some knowledge. Today’s article consist several main topics called Reserve words vs keywords, Identifiers, and Java comments. Let’s see what they are.
- Reserve words and Key words
In java there are 53 reserve words. 50 of them are key words and 3 of them are literals. Other 2 are not in use. Below given image shows some of the reserve words.

- Identifiers
Identifier is a name that we assign to a variable or a class.
eg: class Example{}, int x;, double avg;
Rules for valid(Legal) identifiers
1. There should be only 2 words for an identifier. If you want to use 2 words, you can use ‘_’ sign between those 2 words.
Example:
int my age; ——–> wrong
int my_age; ———> correct
2. For any of the identifier you can use only a-z, A-Z, 0-9, $, _.
3. Can be any length.
4. First letter of an identifier must be a character. You can’t use a number.
Example:
int x2, x3; ———-> correct
int 2x, 3x; ———-> wrong
5. You can’t use any reserve word or a key word.
Example:
int x; ————> correct
int short; ————> wrong
int Short; ————> correct
- Java Comments
Java Comments can be divided into 3 parts.
- Line Comments (//)
- Block Comments (/*……………..*/)
- Document Comments (/**……………..*/)
If you use line comments compiler is not taking it as a byte code. Compiler ignores any line of the code with line comments. Therefore you can use line comment to describe a command in the code.
If you don’t want compile a block of lines in a code, you can use block comment. Compiler ignores the whole block if you use the block comment.

Output is:

When preparing automatically generated document, JDK javadoc (Javadoc is a tool that comes with JDK. It is used to generating java code documentation in HTML format from Java source code, which requires documentation in a predefined format ) tool uses document comment. It is also known as doc comment.
In next article let’s discuss about Conversion and casting. See you guys.
Thank you.


