The BFOIT Java Programming Class
Java Punctuation
Separators are Java's punctuation. Just as
periods, semicolons, question marks, pairs of parenthesis,
and other punctuation add structure to written text, Java
separators help the Java compiler interpret components
of Java source code.
- ( and )
- pairs of parenthesis surround:
- arguments for a method in a method invocation
- method parameters and their type in a method
declaration
- parts/pieces of an expression for
the purposes of controling evaluation
order or simply for clarity
- the mechanics of a for statement
(the initialization, test, and update
pieces)
- the test part of an if statement
- the test part of a while statement
- [ and ]
- pairs of square brackets surround array indicies.
- { and }
- pairs of squiggly brackets surround a few things:
- the body of a class
- the body of a method
- a block of statements to treated as
a unit
- sets of literals for array initialization
- ;
- a semicolon terminates:
- statements
- expression lists, e.g. the mechanics of
a for statement (the initialization,
test, and update pieces)
- field declarations
- ,
- a comma is used to separate items in sets/lists:
- type and identifier pairs in parameter lists
- litterals in an array initialization
- .
- a period is used to:
- separate pieces (identifiers) of a name, e.g.
an object identifier and a field identifier
or an object identifier and method identifier
- separate the whole number part from the fractional
number part of a floating-point literal; it is
the decimal point
Back to Table of Contents