Java shares a common look and feel with C. C++ and Java syntax are similar.
There are three types of comments in Java.
/* This is the main method
and this is a multi-line comment */
public static void main (String args[])
{
boolean completed = false;
int i = 1, j = 1; // an in-line comment
int anArray[] = new int[25];
/* a single line comment */
if ( ! finished )
{
i++;
j += i;
returnVal = anArray[j];
}
}
The Java compiler ignores white space and comments and is parsed into tokens by the compiler. Tokens are the lowest level elements recognised by the compiler. Tokens are made of of the following elements.
| abstract | boolean | break | byte | byvalue | case |
| cast | catch | char | class | const | continue |
| default | do | double | else | extends | false |
| final | float | for | future | generic | goto |
| if | import | inner | instanceof | int | interface |
| long | native | new | null | outer | package |
| private | protected | public | rest | return | short |
| static | super | switch | synchronized | this | throw |
| throws | transient | true | try | var | void |
| volatile | while |
| Primitive types |
| Constants |
| Classes, variables & methods |
| Flow control |
| Scope |
| Exceptions |
| Class definitions |
| Miscellaneous |
| Unused reserved words |