Home : Course Map : Chapter 2 : Java : Keywords
Keywords & Symbols
JavaTech
Course Map
Chapter 2

Introduction
Essentials
Structure

Keywords
Primitive Types
Comments
Literals
Expressions
Operators
Statements
Casts & Mixing
Strings
Console Output 
   Demo
Exercises

    Supplements
Conditional: if-else
Repetitions
Flow Control

Java vs C/C++
JVM Instructions 1

     About JavaTech
     Codes List
     Exercises
     Feedback
     References
     Resources
     Tips
     Topic Index
     Course Guide
     What's New

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

            Tech
Arithmetic Ops
Math Class
More on Integers
FP : Overview
FP : Java  
  
Demo 1
More Mix/Cast
  Demo 2
Exercises

           Physics
Differential Eq.
Euler Method
  
Demo 1
Predictor-Corrector
  
Demo 2
Exercises

  Part I Part II Part III
Java Core 1  2  3  4  5  6  7  8  9  10  11  12 13 14 15 16 17
18 19 20
21
22 23 24
Supplements

1  2  3  4  5  6  7  8  9  10  11  12

Tech 1  2  3  4  5  6  7  8  9  10  11  12
Physics 1  2  3  4  5  6  7  8  9  10  11  12

Java is a trademark of Sun Microsystems, Inc.