Errata for
The Java Programming Language
Fourth Edition
by
Ken Arnold, James Gosling and David Holmes
Second Printing
Get your facts first, then you can distort them as you
please.
-- Mark Twain
This page contains the technical errata -- those things that are wrong or
lead you astray -- in the Second Printing of the book. You may also want to view the minor
errata list, especially before you email us about an error.
You can tell which printing you have by looking at the bottom of the
copyright page (the page that faces the dedication page, and starts with
"Copyright © 2006 by Sun Microsystems, Inc."). The last line on this
page gives the printing number and date.
If you find an error in the book, please check to see if it is already known
before reporting it. If you do not find it in the list, please mail
us the relevant information, including page numbers. All errata will be
fixed in the next possible printing. We are thankful to all
those who have reported errata.
Errata for all printings:
CHAPTER 1: A Quick Tour
CHAPTER 2: Classes and Objects
- Clarification: On page 46 when discussing constant variables there
is one corner case that is not discussed. For the case of a final String
variable, an initialization expression that evaluates to null is
not a constant expression and any such initialized variable is not a
constant variable and its value is not used by the compiler to replace a
reference to the variable. Of course, initializing a final String
variable with the value null is a rather pointless thing to do, so
this case has no practical significance and wasn't considered worth
mentioning.
CHAPTER 3: Extending Classes
- On page 82, where the second sentence of the second paragraph states:
At this stage references to other members of the current object are
permitted, ...
it should say "references to other fields of the current
object". Only fields have the restriction on forward referencing, while
other members (methods and nested types) do not.
CHAPTER 4: Interfaces
CHAPTER 5: Nested Classes and Interfaces
CHAPTER 6: Enumeration Types
CHAPTER 7: Tokens, Values and Variables
CHAPTER 8: Primitives as Types
CHAPTER 9: Operators and Expressions
- Page 205. In discussing the multiple evaluation of the where()
method we state "once to determine the index on the right-hand side and
a second time to determine the index on the left-hand side". This might
give the impression that the right-hand side of the expression is evaluated
before the left-hand side, which is incorrect - the left-hand index is
evaluated first. The use of "left-hand" and "right-hand"
should be switched around.
- Page 218. In the discussion of "Numeric Promotion" the
cross-reference to "Section 9.1 on page 201" should be to
"Section 9.3.2 on page 215".
- Page 227. In the third paragraph the two references to "step
1" should say "step 2"
CHAPTER 10: Control Flow
- On page 232 we discuss the switch statement and how an enum type
can be used as the switch expression, with enum constants as the case
labels. There is an omission in this description due to a late change in the
Java Language Specification, third edition. When the switch expression is of
an enum type, the case labels must be unqualified enum constants of that
type. Allowing the omission of the qualifier on the constant is a nice
convenience, but requiring that it be omitted leads to a strange
inconsistency: the enum contant in the label must be unqualified yet any use
of that same enum constant within the statements for that case must be
qualified (unless the enum constants have been imported through a static
import).
CHAPTER 11: Generic Types
CHAPTER 12: Exceptions and Assertions
CHAPTER 13: Strings and Regular Expressions
CHAPTER 14: Threads
CHAPTER 15: Annotations
CHAPTER 16: Reflection
CHAPTER 17: Garbage Collection and Memory
CHAPTER 18: Packages
CHAPTER 19: Documentation Comments
CHAPTER 20: The I/O Package
CHAPTER 21: Collections
CHAPTER 22: Miscellaneous Utilities
- Page 658. The paragraph after the table of math methods states:
The remainder operator %, as described in "Floating-Point
Arithmetic" on page 202, obeys the rule
(x/y)*y + x%y == x
This is incorrect: the floating-point remainder operator behaves in an
analgous manner to the integer remainder operator, and it is that operator
which obeys the given rule. The rules itself makes no sense if x
and y are floating-point values. The text should simply read:
The remainder operator %, as described in "Floating-Point
Arithmetic" on page 202, behaves in an analogous manner to the
remainder operator for integers.
CHAPTER 23: System Programming
CHAPTER 24: Internationalization and
Localization
- On page 704, in the first example that creates a Japanese
Locale
object, the first argument to the constructor should be "ja"
(the two character language code for Japanese) not "jp"
.
CHAPTER 25: Standard Packages
APPENDIX A: Application Evolution
APPENDIX B: Useful Tables
Further Reading
Index