Identifiers and Keywords in Java


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.

Java Keywords

abstractbooleanbreakbytebyvaluecase
castcatchcharclassconstcontinue
defaultdodoubleelseextendsfalse
finalfloatforfuturegenericgoto
ifimportinnerinstanceofintinterface
longnativenewnullouterpackage
privateprotectedpublicrestreturnshort
staticsuperswitchsynchronizedthisthrow
throwstransienttruetryvarvoid
volatilewhile    
Primitive types
Constants
Classes, variables & methods
Flow control
Scope
Exceptions
Class definitions
Miscellaneous
Unused reserved words