A keyword is a special word. Its meaning is defined by the Java programming language. You cannot use these words as identifiers.
All keywords are in lowercase.
Like everything else in Java, keywords are case sensitive. For example, if you
use For
with uppercase f instead of for
with lowercase f it is an error.
The program shown in the first example
uses four keywords.
* public
* class
* static
and
* void
In Java there are 51 keywords. They’re listed in alphabetical order here.
abstract | assert | boolean | break | byte |
case | catch | char | class | const |
continue | default | do | double | else |
enum | extends | final | finally | float |
for | if | goto | 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 |
_ (underscore) |
Some words are sometimes, incorrectly, assumed as keywords. In any case, they’re reserved in the same way as keywords.
const
and goto
are reserved. They are not used.true
and false
are not keywords. They are boolean literals.null
is not a keyword. It indicates the null literal.var
is not a keyword. It is a special identifier.