Keywords and Identifiers

A keyword is a word whose meaning is defined by the programming language.

Java Keywords and Reserved Words:

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

An identifier is a word used by a programmer to name a variable, method, class, or label.

Keywords and reserved words may not be used as identifiers.

An identifier must begin with a letter, a dollar sign ($), or an underscore (_); subsequent characters may be letters, dollar signs, underscores, or digits.

Some examples are:


foobar          // legal
Myclass         // legal
$a              // legal
3_a             // illegal: starts with a digit
!theValue       // illegal: bad 1st  char

Identifiers are case sensitive.

For example, myValue and MyValue are distinct identifiers.

Home 
  Java Book 
    Language Basics  

Keywords:
  1. Keywords and Identifiers
  2. Using identifiers