Keywords

   

Before you set off on a more in-depth exploration of each of the topics discussed in this chapter, there are a few other basic concepts that need to be introduced.

The most important of these is the use of keywords in Java. There are certain sequences of characters , called keywords, which have special meaning in Java. The following is a list of the 51 keywords defined as part of the language. After you learn the implications and proper use of these terms, you will have a solid understanding of the Java fundamentals.

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

Note

The keywords const and goto are reserved words that have no meaning in Java. goto is reserved just so it can never be used in a Java program, even as an identifier name .


The reason you care about keywords is that these terms have specific meaning in Java; you cannot use them as identifiers for anything else. If HelloApplet were on the list, the compiler would have reported an error when compiling that class for you. Besides class names, keywords cannot be used as variables , constants, method names , and so on. However, they can be used as part of a longer token, for example:

 public int abstractInt; 

Because Java is case sensitive, you can add one or more uppercase letters to a keyword and use it as an identifier if you are determined to do so. Although this is possible, it would do nothing but cause confusion to others reading your code. You should always treat the reserved words as reserved and keep your identifier names distinct.

   


Special Edition Using Java 2 Standard Edition
Special Edition Using Java 2, Standard Edition (Special Edition Using...)
ISBN: 0789724685
EAN: 2147483647
Year: 1999
Pages: 353

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net