book banner gif

home button gif from book button gif software button gif

ch01 ch02 ch03 ch04 ch05 ch06 ch07 ch08 ch09 ch10 ch11 ch12 ch13 ch14 ch15 ch16

Appendix A: The Java Language


Reserved Words (Keywords)
abstract double int super
boolean else* interface switch*
break* extends long synchronized*
byte final native this
case* finally new* throw**
catch** float package throws
char for* private transient***
class goto*** protected try**
const*** if* public void
continue* implements return* volatile***
default* import short while*
do* instanceof static

The above words are class or data declaration or identification, unless specified otherwise (see below).



  * normal flow control or object construction

 ** exception handling

*** reserved but ignored by Java 1.0.x compilers (italics indicate words with
specified meanings to be supported in future versions of Java: see glossary)


Reserved Words (Literals)
true
false
null

Markings and Special Characters-Comment Delimiters
Delimiter Meaning
/** Begin documentation comment
/* Begin indefinite comment
*/ End indefinite comment
// Comment to end of line

Character Escape Sequences (for Use in char '' and string "" Literals)
Meaning Literal representation ASCII code (decimal) ASCII code (hexadecimal) Unicode
backspace \b 8 08 \u0008
tab \t 9 09 \u0009
new line \n 10 0A \u000A
form feed \f 12 0C \u000C
line return \r 13 0D \u000D
double quote \" 34 22 \u0022
single quote \' 39 27 \u0027
backslash \\ 92 5C \u005C

Octal and Unicode Character Constant Formats
Numeric Format and Range Meaning
\0 through \377 Octal value of character (<= \u00FF)
\u0000 through \uFFFF Unicode hexadecimal value of character

Operators and Precedence Groups-from Highest to Lowest Precedence (Modifiable by Parentheses)
Group Operator(s) Meanings
Postfix operators [] array access
. member access, method invocation
() method application
++ increment after current value return
-- decrement after current value return
Prefix operators ++ increment before current value return
-- decrement before current value return
+ unary plus (redundant)
- unary minus (multiplies by -1)
~ bitwise complement
! Boolean complement
Prefix constructives new invoke constructor
(<type>) cast to <type>
Multiplicatives * / %
Additives + -
Bit manipulatives >>> >> <<
Comparatives < <= >= > instanceof relative order class membership
Identities == !=
bitwise/boolean AND &
bitwise/boolean XOR ^
bitwise/boolean OR |
boolean conditional AND &&
boolean conditional OR ||
ternary conditional ?:
assignments = *= /= %= += -= <<= >>= >>>= &= ^= |= (i) active assignments have semantics i = i <modifier> j: e.g., i += j denotes i = i + j (ii) multiple assignments are processed from right to left: e.g., a=b=c denotes a=(b=c). All other operators of equal precedence are processed from left to right.


Global Constants (Public Static Values)

Use of these values improves clarity of code and enhances compatibility with future versions of Java or with installations on new classes of hardware. Checking of values against constraints such as Integer.MAX_VALUE reduces the likelihood of uncaught exceptions. Defining your own public static constants is an effective practice when designing your own classes.
Partial Listing in Format Class.NAME
Boolean.FALSE Event.KEY_ACTION Event.WINDOW_MOVED
Boolean.TRUE Event.KEY_ACTION_RELEASE FileDialog.LOAD
Character.MAX_RADIX Event.KEY_PRESS FileDialog.SAVE
Character.MAX_VALUE Event.KEY_RELEASE Float.MAX_VALUE
Character.MIN_RADIX Event.LEFT Float.MIN_VALUE
Character.MIN_VALUE Event.LIST_DESELECT Float.NaN
Color.black Event.LIST_SELECT Float.NEGATIVE_INFINITY
Color.blue Event.LOAD_FILE Float.POSITIVE_INFINITY
Color.cyan Event.LOST_FOCUS FlowLayout.CENTER
Color.darkGray Event.MOUSE_DOWN FlowLayout.LEFT
Color.gray Event.MOUSE_DRAG FlowLayout.RIGHT
Color.green Event.MOUSE_ENTER Font.BOLD
Color.lightGray Event.MOUSE_EXIT Font.ITALIC
Color.magenta Event.MOUSE_MOVE Font.PLAIN
Color.orange Event.MOUSE_UP Integer.MAX_VALUE
Color.pink Event.PGDN Integer.MIN_VALUE
Color.red Event.PGUP Label.CENTER
Color.white Event.RIGHT Label.LEFT
Color.yellow Event.SAVE_FILE Label.RIGHT
Double.MAX_VALUE Event.SCROLL_ABSOLUTE Long.MAX_VALUE
Double.MIN_VALUE Event.SCROLL_LINE_DOWN Long.MIN_VALUE
Double.NaN Event.SCROLL_LINE_UP Math.E
Double.NEGATIVE_INFINITY Event.SCROLL_PAGE_DOWN Math.PI
Double.POSITIVE_INFINITY Event.SCROLL_PAGE_UP Scrollbar.HORIZONTAL
Event.ACTION_EVENT Event.UP Scrollbar.VERTICAL
Event.DOWN Event.WINDOW_DEICONIFY Thread.MAX_PRIORITY
Event.END Event.WINDOW_DESTROY Thread.MIN_PRIORITY
Event.GOT_FOCUS Event.WINDOW_EXPOSE Thread.NORM_PRIORITY
Event.HOME Event.WINDOW_ICONIFY


The ASCII Character Set

In this 7-bit code, with possible values 0 through 127, the first 32 values (0 through 31 decimal, 00 though 1F hex) are used by control characters such as backspace (decimal 8), tab (decimal 9), and form feed (decimal 12).

These control codes, and others, have special literal representations that are tabulated elsewhere in this appendix. Those literal representations should be used for both clarity and correctness. For example, '\n' should be used for a line feed rather than the equivalent Unicode escape sequence, \u000a, since the latter will be translated into an actual line feed at an early stage in the processing of the source code file.

This means that the statement



System.out.println('\u000a');


will look to the compiler like



System.out.println('

');


and will produce several error messages. The statement



System.out.println('\n');


will behave as one would expect.

Other low-group codes, such as 22 ("synchronous idle"), are relics of an earlier generation of communications equipment. The assignment of code 127 to mean "deleted" reflects the use of punched cards and paper tape: In binary, this code consists of seven 1s, represented by punching out all seven possible holes, obscuring whatever was encoded before on that card or in that position on the tape.

The numeric digits, the uppercase letters, and the lowercase letters have the same numeric code values in the 7-bit ASCII, the 8-bit ISO-Latin-1, and the 16-bit Unicode schemes.


ASCII Character Set
Decimal Hexadecimal Character
32 20 <space>
33 21 !
34 22 "
35 23 #
36 24 $
37 25 %
38 26 &
39 27 '
40 28 (
41 29 )
42 2A *
43 2B +
44 2C ,
45 2D -
46 2E .
47 2F /
48 30 0
49 31 1
50 32 2
51 33 3
52 34 4
53 35 5
54 36 6
55 37 7
56 38 8
57 39 9
58 3A :
59 3B ;
60 3C <
61 3D =
62 3E >
63 3F ?
64 40 @
65 41 A
66 42 B
67 43 C
68 44 D
69 45 E
70 46 F
71 47 G
72 48 H
73 49 I
74 4A J
75 4B K
76 4C L
77 4D M
78 4E N
79 4F O
80 50 P
81 51 Q
82 52 R
83 53 S
84 54 T
85 55 U
86 56 V
87 57 W
88 58 X
89 59 Y
90 5A Z
91 5B [
92 5C \
93 5D ]
94 5E ^
95 5F _
96 60 `
97 61 a
98 62 b
99 63 c
100 64 d
101 65 e
102 66 f
103 67 g
104 68 h
105 69 i
106 6A j
107 6B k
108 6C l
109 6D m
110 6E n
111 6F o
112 70 p
113 71 q
114 72 r
115 73 s
116 74 t
117 75 u
118 76 v
119 77 w
120 78 x
121 79 y
122 7A z
123 7B {
124 7C |
125 7D }
126 7E ~
127 7F <deleted>


ch01 ch02 ch03 ch04 ch05 ch06 ch07 ch08 ch09 ch10 ch11 ch12 ch13 ch14 ch15 ch16

home button gif from book button gif software button gif
Hosted by www.Geocities.ws

1