|
Instant eXpert Guides |
Many computer languages have reserved words, key words, or protected words.
These are words that cannot be redefined or declared as new variables, methods or functions.
This article provides information about reserved words in the Java programming language.
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
To quote the Java Tutorial from java.sun.com, "These words are reserved. You cannot use any of these words as names in your program." However, this explanation may not be totally satisfying to inquiring minds who are always asking why...
We say the Java key-words are reserved words or protected words, or we might use the term immutable or immutability. James Gosling (and the other authors/creators of Java) have protected these words, so that no one can change their attributes, definition, interpretation, perspicuity, specification, or meaning.
A computer language creator has to make choices of setting some basic rules for the language, so that it will have enough logic to perform some useful work. Without some basic rules, language anarchy would be the result, and the language would quickly self destruct and be useful to no one.
Key-words may need to be global in scope, so that all other classes, functions, programs, scripts, methods or modules can use those key-words to perform declaration of data types, or control flow logic.
For example: boolean is the logical data type, and has two values of true and false. The definition for the key-words of boolean, true, and false are protected so that someone could not come along and destroy your program by reversing the meaning of true and false (making true = false, and making false = true).
"Woe unto them that call evil good, and good evil; that put darkness for light, and light for darkness; that put bitter for sweet, and sweet for bitter!" - Isa 5:20
"If all creeds are equally true, then since they are contradictory to one another, they are all equally false, or at least equally uncertain. We are indulging, therefore, in a mere juggling with words." - J. Gresham Machen
The Java reserved words can be classified in several groupings relating to the origin or purpose of the word. Java grammar and syntax provides the language structure and reveals the word classes (or word groups), such as primitive data types, statements, modifiers.