The table below lists the keywords, or reserved words, as
of Java 5.0. We will discuss the meaning and function of most of
them during this course.
Keywords
|
abstract
assert
boolean
break
byte
case
catch
char
class
const
continue
default
do
double
else
enum
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 |
Notes
- The goto
keyword is not used. (In modern language design, such
jumping between lines of code is considered very bad programming
practice.)
- const
is also not used.
- assert
is a new keyword added with Java 1.4
- enum
is a new keyword added with Java 5.0.
Java is case sensitive so in principle you
could use these words if you change any character to uppercase.
But that's not recommended!
|
Reserved Symbols in
Java |
; |
Semi-colon indicates the end of a statement. |
() |
Parentheses used in several places including:
- Overrides the default precedence
in an expression that contains multiple operators.
- Indicate a method or casting operator (see Operators).
- Surround the logic test in an if
statement, e.g.
if(test)...
|
[] |
- array declaration.
- array element specification
|
{} |
Curly braces
- enclose the fields and methods of a class.
- enclose the code for a method.
- Enclose the code body for an if
statement, a for
loop statement, a synchronized block, and initial
values for an array declaration.
|
// |
Indicates a single line comment |
/*..*/
or
/**..*/ |
- Bracket a set of comments that can span more than
one line.
- Same as /*
*/ except that the double astericks
tell the javadoc program to use the comments in
its output.
|
: |
Colon is used in switch statements and
the conditional operator. |
"xx" |
Double quotes surround a string literal. |
'x' |
Single quotes surround a character literal. |
+,-,etc |
Operator symbols. See Operators
for listing. |
@ |
Used with annotation. (J2SE
5.0) |
<> |
Indicates generics. (J2SE
5.0) |
% |
Used with the Formatter
class and printf() to specify output formats. (J2SE
5.0) |
? |
Used with the conditional
operator
x = boolean ? y : z;
As of Java 5.0, '?' acts also as a type wildcard in
generics. |
Notes
- Identifiers (i.e. the names of
data, methods and classes) cannot begin with a number.
- Whitespace (space, line return)
is ignored in Java code.
- Non-printing ASCII characters use
backslash, e.g. '\t' - tab, '\n' - return
- Unicode character specified with
'\u + 4 hex values', e.g. '\u03c0' - pi
|
|
References & Web Resources
Latest update: Oct. 13. 2004
|