Java Reference
In-Depth Information
Table A.1.2
Reserved symbols in Java.
Symbol
Description
Semi-colon indicates the end of a statement.
;
Parentheses are used in several places. They override the default precedence in an
expression that contains multiple operators.
They indicate a method and also a casting operator. They surround the logic test in an
if statement, e.g.
()
if (test) doSomething();
[]
Array declaration and an array element specification.
{}
Curly braces enclose the fields and methods of a class, the code for a method, 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.
//
Bracket a set of comments that can span more than one line.
The /** */ version is the same as /* */ except the double asterisks tells javadoc to
use the comments in its output.
/*. .*/
or
/**. .*/
Colon is used in switch statements and the conditional operator. Also, it is used in the
enhanced for-loop.
:
“xx
Double quotes surround a string literal.
Single quotes surround a character literal.
` x'
+,-, etc
Operator symbols. See Appendix 2 for a listing of operators.
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 (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' = π .
Search WWH ::




Custom Search