Reserved and restricted keywords
The keywords are the words that have particular meaning for a compiler and cannot be used as identifiers. As of Java 17, there are 52 reserved keywords, 5 reserved identifiers, 3 reserved words, and 10 restricted keywords. The reserved keywords cannot be used as identifiers anywhere in the Java code, while the restricted keywords cannot be used as identifiers only in the context of a module declaration.
Reserved keywords
The following is a list of all Java-reserved keywords:
By now, you should feel at home with most of the preceding keywords. By way of an exercise, you can go through the list and check how many of them you remember. Up until now, we have not discussed the following eight keywords:
const
andgoto
are reserved but not used, so far.- The
assert
keyword is used in anassert
statement (we will talk about this in Chapter 4, Exception Handling). - The
synchronized
keyword is used in concurrent...