Java Keywords: Currently there are 50 reserved words in Java language. These keywords cannot be used as names of a variable, class or method but they can be combined with other characters or symbols to be used as the name of any variable, class or method.
[
Note:
1. const and goto are reserved words in Java language but are not used.
2. true, false and null are not part of Java keywords list but still they are also reserved words in Java language.
]
Updated list of Java Keywords as of version 6 is following:
Java Keywords :
|
- Identifiers can begin with a letter, an underscore, or a currency character.
- After the first character, identifiers can contain any combination of letters, currency characters, connecting chracters, or numbers.
- Identifiers can be of any length.
- Identifiers are case-sensitive.eg. foo and Foo are two different identifiers.
- Java keywords(for list of Java keywords refer any Java book) cannot be used as identifier.
Few of the legal identifiers are :
| int _a; int this_is_a_very_detailed_name_for_an_identifier; int _$; int ________2_w; int $c; |
Few of the illegal identifiers are :
| int :b; int .f; int 7g; int -d; int e#*; |
Comments: Basically there are three types of comments used in Java language.
1. single-line comment : It is used to comment only one-single line. These comments start with // at the starting of the code line to be commented.
Example: // System.out.println("Hello");
2. multi-line comment : It is used to comment more than one line. These comments start with /* at starting code line and ends with */ at the ending code line.
Example:
/*public static void main(String[] args){
System.out.println("Hello");
}*/
3. documentation comment : Generally it is used to produce an HTML file that documents our program. These comments start with /** and ends with */ and all in between lines are prefixed with * at the starting.
Example:
/**
* This method prints "Hello"
* @author shalinig
*/
public static void main(String[] args){
System.out.println("Hello");
}
Feel free to fire questions! :)