Friday 1 March 2013

Java Tokens and Keywords


Java Tokens: Tokens are smallest individual units in a program.  The compiler reads the source program one character at a time grouping the source program into a sequence of atomic units called Tokens.  Reserved words, identifiers, constants, operators etc., are the examples of Java Tokens.

Keywords: The Keywords or Reserved words are one, which have a special and predefined meaning to the Java compiler.  There are 48 reserved words currently used in Java.  These words cannot be used as names for a variable, constant, class or method.  Reserved words are

abstract            boolean            break               byte                 case                 catch
char                 class                 const                continue          default             do
double             else                  extends            final                 finally              float
for                   goto                 if                      implements      import              instanceof
int                    interface          long                 native              new                 package
private             protected         public              return               short                static
strictfp             super                switch              synchronized   this                  throw
throws             transient          try                    void                 volatile                        while
true                  false                 null

Note: const and goto are reserved for future use.  Java reserved words true, false and null reserved words are used to represent the values.

No comments:

Post a Comment