Welcome to the Core Java Bug List

Fourth (Java 2) Edition Bugs

Volume 1 {short description of image}

* = fixed in second printing

# = fixed in third printing

#Page 2 second paragraph
Change "due its portability" to "due to its portability"
*Pages 3 (2x), 16 (2nd occurrence), 17, 39, 261, 265 (2x), 540
Change "Java 1.2" to "Java 2"
#Page 3
"...Windows 95/98. NT, Solaris, ..." should be "...Windows 95/98 /NT, Solaris, ..."
Page 8
Change "Java 1.1 now has the notion of signed classes" to "Java now has the notion of signed classes".
Page 11
Remove the sentence "(Actually, it is the bytecodes...and then run)".
#Page 16 first line
Add a period after "canvas" and before the closing parenthesis.
*Page 16
After the sentence "The big news of the 1998 JavaOne conference was the upcoming release of Java 1.2, which replaces the early toy-like GUI and graphics toolkits with sophisticated and scalable versions that come a lot closer to the promise of “write once, run any-where” than their predecessors.", insert: "Three days after (!) its release in December 1998, the name was changed to Java 2."
#Page 16 last paragraph
Change "The Java library contains over 150 classes and interfaces" to "The Java library contains over 150 0 classes and interfaces". Change "Just listing every possible function and constant in the library along with a one- or two-sentence description of them takes more than 250 pages." to "Just listing every possible function and constant in the library takes more than 600 pages in the Java Developers Almanac.". Change "Luckily you do not need to know every function and constant listed in the 250 pages of the (hypertext-based) Java Aplication Programming User's Guide" to "Luckily you do not need to know every one of the 20,000+ entries in the Java Developers Almanac
Page 19
"...but it so boringly obvious..." should read "...but it is so boringly obvious..."
#Page 22 last paragraph
Change "an excellent shareware programming editors" to "an excellent shareware programming editor".
#Page 23
Remove 2nd "used" from "...and manually add the special files that we use used in this book."
Page 23
"...since you have often have to set..." should read "...since you often have to set..."
*Page 24
Change "the classpath environment variable" to "the CLASSPATH environment variable".
Page 25
Change "If you have done all your programming in the various version of Windows" to "If you have done all your programming in the various version s of Windows"
#Page 26
In the caution warning, replace "CLASSES.ZIP in the lib directory" with "rt.jar in the \jdk\jre\lib directory".
#Page 27 first word
Remove "with"--it is repeated from the last word on page 26.
Page 36 ImageViewer.java
Change chooser.getSelectedFile().getName() to chooser.getSelectedFile().get Path()
*Page 40 WelcomeApplet.java
In the init method, change JButton cayButton = new JButton("Cay Horstmann"); to cayButton = new JButton("Cay Horstmann"); and change JButton garyButton = new JButton("Gary Cornell"); to garyButton = new JButton("Gary Cornell");
#Page 44 middle of page
Change "(such as typing Main instead of main), the program will not compile" to "(such as typing Main instead of main), the program will not run".
#Page 46
Remove unmatched ending ) at the end of the VB Note.
*Page 46
Change "Java always uses the general syntax object.method(parameters) " to "Java uses the general syntax object.method(parameters) "
Page 50
Remove the sentence "They will overflow on range errors and underflow on operations like a divide-by-zero."
Page 50
"For example. 'H'..." should read "For example, 'H'..." . "...character, "H" is a string..." should read "...character, and"H" is a string..."
*Page 55
Change "byte -> short -> int -> long -> float -> double" to "byte -> short -> int -> long -> float -> double and char -> int"
#Page 56
Change "part of the Math class in Java.lang" to "part of the Math class in java.lang"
Page 57
"...many of C++ more bug-prone..." should read "...many of C++ 's more bug-prone..."
Page 58
Change "the exclamation point is the negation operator" to "the exclamation point is the logical negation operator".
*Page 67
Change "your CLASSPATH environment variable as described in chapter 2" to "your CLASSPATH environment variable as described in appendix III"
Page 68
Change "You then apply the format method to the NumberFormat object to get a string that contains the formatted number." to "You then apply the format method of the NumberFormat object to get a string that contains the formatted number."
#Page 69
Change:
NumberFormat nf = NumberFormat.getNumberInstance(Locale.GERMAN);
System.out.println(nf.format(x));
NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.GERMANY);
to:
NumberFormat nf = NumberFormat.getNumberInstance(Locale.GERMAN);
System.out.println(nf.format(x));
nf = NumberFormat.getCurrencyInstance(Locale.GERMANY);
That is, change GERMAN to GERMANY (2x) and drop the second NumberFormat
Page 69
Really change:
NumberFormat nf 
= NumberFormat.getNumberInstance(Locale.GERMANY);
System.out.println(nf.format(x));
NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.GERMANY);
to:
NumberFormat nf = NumberFormat.getNumberInstance(Locale.GERMANY);
System.out.println(nf.format(x));
nf = NumberFormat.getCurrencyInstance(Locale.GERMANY);
System.out.println(nf.format(x));
*Page 70
In the table entry for %, change "Divide by 100" to " Multiply by 100"
Page 71
Change void DecimalFormat(String pattern) to DecimalFormat(String pattern)
*Page 72
Change String s = new Format.form to String s = new Format
#Page 72
Change "x Integer in hexadecimal" to "x, X Integer in hexadecimal (with lower- or uppercase letters)
Page 77
Change {yourSales >= 1.5 * target) to (yourSales >= 1.5 * target)
#Page 77
Change if (x != 0 && 1 / x > 0) to if (x != 0 && 1 / x + y > x). (Editorial note: As Marcia Perry points out, the original condition is equivalent to x > 0 .)
#Page 79 Retirement.java
Change Your can retire in to You can retire in.
*Page 87
In the last paragraph, change "parameters" to "arguments" (2x)
*Page 88
Change "More precisely, when Java calls a method, all local variables are initialized..." to ""More precisely, when a method is executed, its local variables are initialized...""
Change "When Java exits a method..." to "When the method exits..."
Page 91
Change "Both types of recursion are possible with Java methods and (unlike Pascal, say)" "Both types of recursion are possible with Java methods and (unlike in Pascal, say)"
*Page 93
Change "Java has a shorthand to create an array object and initialize it at the same time." to "Java has a shorthand to create an array object and supply initial values at the same time."
#Page 93
The last value of Figure 3-8 should be 12, not 13.
#Page 97
Change + It'll make you rich!"); to: + "It'll make you rich!");
Page 97 LotteryDrawing.java
Change
int numbers[] = new int[high];
int result[] = new int[number];
to
int[] numbers = new int[high];
int[] result = new int[number];
Page 98
Change "-r + 1 is the spot at which v should be inserted" to "-r - 1 is the spot at which v should be inserted"
#Page 98
Change static void equals to static boolean equals . Change "returns true if object is an array of the same type" to "returns true if other is an array of the same type"
Page 99
Change the caption for table 3-7 to: "Growth of an investment".
#Page 103
Format.print("%4d", odds[i][j]); should be Format.printf ("%4d", odds[i][j]);
Page 111
In line 3, change "account objects" to "Account objects"
*Page 112
Change "Universal Modeling Language" to "Unified Modeling Language"
Page 115
Change "(See Figure 4-6)" to "(See Figure 4-6.)"
#Page 118
(1999, Calendar.DECEMBER, 11, 31, 23, 59, 59) should be (1999, Calendar.DECEMBER, 31, 23, 59, 59)
Page 118
Add the to "...which is used in VB to denote an example of the Date type."
Page 123
In line 11, change getTimeinMillis to getTimeInMillis
Page 123
Change "a better example of a class with cleanly designed accessor and mutator functions" to "a better example of a class with cleanly designed accessor and mutator methods"
#Page 124
Change
("Please enter the month you were born,
1 for January and so on");
to
("Please enter the month you were born, "
   + "1 for January and so on"); 
Page 126
Change "since objects are references" to "since objects are always accessed through references"
*Page 128
Change "Both objects and base types such as numbers are always passed by value" to "Both object references and base types such as numbers are always passed by value".
Page 129 and EmployeeTest.java
Add the following method to the Employee class:
public String getName()
{ return name;
}
This method is referenced on page 135
#Page 130
Change "Notice that this file (sometimes it's called a compilation unit) contains the source code for two classes:" to "On the CD ROM, we placed both classes into a single source file. This file contains the source code for two classes:". Change "You must save this file with the name EmployeeTest.java" to "We had to give this file the name EmployeeTest.java".
Page 131
"...has four methods..." needs to be changed to "...has five methods..." and add "public String getName()" to the list.
#Page 134
The last two paragraphs on this page must be swapped. The paragraph at the bottom of the page which begins with "The raiseSalary method is a function ..." should be moved up one paragraph to immediately precede the paragraph that begins with "Of the remaining methods in this class ...".
#Page 134
Change "For example, double byPercent" to "For example, double byPercent" (i.e. set double in Courier)
Page 142 last paragraph
Change "There is a actually a..." to "There is actually a..."
Page 143
Change the details of what happens when a constructor is called to the following:
  1. All instance fields are initialized to their default value (0, false or null).
  2. If the first line of the constructor calls another constructor, then that constructor is executed. Otherwise, all field initializers and initialization blocks are executed, in the order in which they occur in the class declaration.
  3. The body of the constructor is executed.
*Page 143
Change "This mechanism is never necessary and it is common" to "This mechanism is never necessary and it is not common"
#Page 144
Change the NOTE to: "NOTE: There is a method System.runFinalizersOnExit to guarantee that finalizer methods are called before Java shuts down. However, this method is inherently unsafe and has been deprecated in Java 2."
#Page 145
Change "public static final CM_PER_INCH" to "public static final double CM_PER_INCH"
Page 146
Change "Because of this, main can only access static instance fields of the class" to "Because of this, main can only access static fields of the class".
#Page 147
Point 3, "assesses" should be "accesses"
Page 147
Change "The size of the array and the array itself are made class constants (ie., declared with private static final)" to "The size of the array and the array itself are declared static."
*Page 148 RandomIntGenerator.java
In the draw method, remove the line if (r > high) r = high;
#Page 148 RandomIntGenerator.java
In the nextRandom method, remove the line if (pos == BUFFER_SIZE) pos = BUFFER_SIZE - 1;
*Page 151 CardDeck.java
Change void play(int rounds) to public void play(int rounds)
#Page 154
Change "but if the current directory (.) is part of the class path" to "but if the current directory (. ) is part of the class path". (I.e. class not in Courier)
#Page 156
Change c:\jdk\lib\classes.zip into c:\jdk\jre\lib\rt.jar (2x)
Page 156
Change "so there are three directories to search in our example." to "so there are two directories to search in our example."
#Page 157
Change "For example, the class Card in the CardDeck example you saw earlier was not defined as a public class, so only other classes in the same package" to "For example, if the class Card in the CardDeck example you saw earlier was not defined as a public class, then only other classes in the same package"
#Page 158
Change public void trustMe to public static void trustMe.
#Page 160
Change public void CardDeck() { . . . } to public CardDeck() { . . . }
#Page 167
In Example 5-1, replace:
Manager boss = new Employee("Harry Hacker", 35000,
new Day(1989,10,1));
with:
Manager boss = new Manager("Carl Cracker", 75000,
new Day(1987,12,15))
;
Note: The companion source file is correct.
#Page 168
Replace:
staff[1] = new Manager("Carl Cracker", 75000,
new Day(1987,12,15));
with
 staff[1] = new Employee("Harry Hacker", 35000,
new Day(1989,10,1))
;
Note: The companion source file is correct.
Page 170
Change "in inheritance subclass objects have at least as many data fields as superclass objects" to "subclass objects have at least as many data fields as superclass objects"
Page 170 in the C++ note
Change "see the section on Interfaces in the next chapter" to "see the section on interfaces in the next chapter"
Page 173
Change "converts the variable x into an integer, discarding the fractional part" to "converts the value of the expression x into an integer value, discarding the fractional part"
Page 178
Change "They must be in .au format." to "They can be in .au or .wav format."
*Page 180 MailboxTest.java
Change private final int MAXMSG = 10; to private static final int MAXMSG = 10;
*Page 183
Change "For example, you have seen the toString method used with the Day class to give a string representation of the date." to "For example, the toString method of the Day class gives a string representation of the date."
#Page 183 second paragraph from bottom
Change "Another important method in Object is the toStrin g method" to "Another important method in Object is the toString method".
*Page 185
Change the first occurrence of
for (i = 0; i < n; i++) a[i].raiseSalary(3);
to
for (i = 0; i < n; i++) arr[i].raiseSalary(3);
Change the second occurrence to
for (i = 0; i < n; i++) arr[i]->raiseSalary(3);
Change
Employee** a; // C++
Object** arr = a;
to
Employee** staff; // C++
Object** arr = staff;
Page 185
Change arr[i].raiseSalary(3) to staff[i].raiseSalary(3) . Change arr[i]->raiseSalary(3) to staff [i]->raiseSalary(3) . (And set the -> as a Courier - followed by a Courier >.)
#Page 187
Change "Use the addElement method" to "Use the add method".
#Page 190
Change "Accessing Vector Element" to "Accessing Vector Element s"
*Page 190, 198
Change "version 1.2" to "Java 2".
#Page 191
Change "--see the next section)" to "--see the next section.)" (I.e., add a period before the closing parenthesis.)
#Page 191
Change "And it is unique to vectors because they store values of type Object" to ""The problem arises because vectors store values of type Object"".
Page 193
Change "...and the size of the array is reduced by one." to "...and the size of the vector is reduced by one."
Page 193
Change void remove to Object remove. After "...and shifts down all elements above it.", add " Returns the removed element."
Page 195
Change v.set(i, new Integer(r.intValue() + 1); to v.set(i, new Integer(r.intValue() + 1)); (i.e. add a closing parenthesis at the end).
#Page 195
Change: "The wrapper classes have obvious names: Integer, Long, Float, Double, Byte, Character , Void, and Boolean. (The first five inherit from the common parent wrapper Number.)" to "The wrapper classes have obvious names: Integer, Long, Float , Double, Short, Byte , Character , Void, and Boolean. (The first six inherit from the common parent wrapper Number .)"
#Page 196
Change ".doubleValue()" and "Double" to "doubleValue()" and "Double". (I.e. drop the unnecessary period and fix up the fonts.)
#Page 197
In the note, change IntegerHolder to IntHolder.
Page 199
Change "equivalent of the number object, ..." to "equivalent of the Number object, ..."
*Page 200
Change "you can turn to a couple of handy subclasses of the Math class..." to "you can turn to a couple of handy classes in the java.math package..."
Page 202 first paragraph
Change "Click on any package, and all classes on that window..." to "Click on any package, and all classes on that package..."
#Page 203
Change item 4 to: "4. Click on any field or method name for a detailed description (see Figure 5-5)." Eliminate item 6.
#Page 206
Change "The parameters supplied to the constructor" to "the parameters supplied to the constructor"
Page 207
Change "The three classes . . . in java.lang.reflect package" to "The three classes . . . in thejava.lang.reflect package"
Page 207
Change "You can then use the static methods in the Modifier class in java.lang.reflect to analyze the integer that getModifiers returns." to "You can then use the static methods in the Modifier class in the java.lang.reflect package to analyze the integer that getModifiers returns."
#Page 214 and ObjectAnalyzerTest.java
The line: r += val.toString; should be: r += val.toString ();
Page 216 line 1
Remove the period after AccessibleObject
#Page 217
Change "To get the component type of the new array." to "To get the component type of the new array," (i.e. change the period to a comma)
Page 217, 219, 220
Change a.getClass().getComponentType() to cl.getComponentType()
Page 221
In lines 3 and 4, remove the System.out as a parameter to the printf method.
Page 221
Change "Example 5-8: MethodPointerTest" to "Example 5-8 MethodPointerTest .java"
#Page 222 (2x)
Change Format.printf(System.out, "%12.4f...) to Format.printf("%12.4f...) . That is, remove System.out from both calls to Format.printf .
#Page 226
Change "&& temp.compare(..." to "&& temp.compareTo(..."
Page 227
Remove the main method (i.e. public static void main, the blank line preceding it and the next five lines following it).
#Page 227
Change "Example 6-1: EmployeeSortTest" to "Example 6-1: EmployeeSortTest .java"
#Page 228 EmployeeSortTest.java
In the hireYear method, change return 1900 + hiredate.getYear() to return hiredate.getYear()
Page 231
In the C++ note, change "mixin" to "mix in" (2x)
Page 232
Change "Next, just as you use instanceof to check if a object..." to "Next, just as you use instanceof to check if an object... "
Page 233
Change "(See Figure 6-1)." to "(See Figure 6-1.)"
*Page 236
Change
e.hireDay = hireDay.clone();
to
e.hireDay = (Day)hireDay.clone();
Page 238
Change TimerListener listener; to private TimerListener listener;
*Page 243
Change "The name isSet refers to the field of the inner object; the name salary refers to the outer object." to "The name isSet refers to the isSet field of the inner object; the name salary refers to the salary field of the outer object."
#Page 249
Replace the sentence "Of course, since Java source names cannot contain $ characters, one cannot simply place a call access$1(harry) into a Java program and compile it." with "The Java language standard reserves $ characters in variable and method names for system usage."
#Page 250
Remove the space before the () in "return new Property ()".
Page 250, 254
Add ; after the closing brace under
return new Property()
{
. . .
} // add ; here
*Page 265 (2x)
Change "1.2" to "Java 2"
Page 265
Change "Note that does not..." to "Note that this does not..."
#Page 266
JFrame = new FirstFrame(); should read: JFrame frame = new FirstFrame();
#Page 268
Change "Alternatively, under Windows 95/98 or NT, you can carefully press CTRL-ALT-DEL" to "Alternatively, under Windows 95/98, you can carefully press CTRL-ALT-DEL"
Page 269
Change WindowListener exitOnClose = New Terminator(); to Terminator exitOnClose = New Terminator(); (for consistency with page 329)
Page 272
In line 1, change "display the component" to "display the frame ".
#Page 272
In the tip, change "the API notes only list overridden methods" to "the API notes only explain overridden methods" and "and it isn't listed in the documentation" to "and it isn't explained in the documentation"
#Page 281
Change "void paintComponent(Graphics. g)" to " void paintComponent(Graphics g)" (no bold, no period)
Page 281
In the API note for java.awt.Component, remove "by calling update" (2x)
*Page 281-282
Change
Font helvb14 = new Font("Helvetica Bold", Font.PLAIN, 14);
to
Font helvb14 = new Font("Helvetica", Font.BOLD, 14);
Remove the sentence "When you specify a font by its face name you always use Font.PLAIN as the second argument of the constructor."
(Editorial comment: The removed sentence described the behavior in 1.2Beta4. 1.2 FCS did not let you request "Helvetica Bold"--youl got plain Helvetica instead. I am hesitant to add a sentence "The suffix Bold or Italic is ignored" because I am not confident that behavior is stable. At Java One in May 1999, a presentation from the Java 2D group falsely suggested that it is safe to add Bold in the font name and Font.PLAIN in the style. This seems to be a bug that cycles back and forth. Of course, either call ought to obtain the bold font.)
*Page 285
Change "Making the fonts and font metrics into variables of our extended Frame class" into "Making the fonts and font metrics into variables of our frame class".
*Page 292
Change
Color(byte redness, byte greenness, byte blueness)
to
Color(int redness, int greenness, int blueness)
Page 292
Change "an ancestor of JFrame" to "an ancestor of JPanel ". Change
JFrame f = new MyFrame();
f.setBackground(Color.white);
f.show();
to
MyPanel p = new MyPanel();
p.setBackground(Color.white);
contentPane.add(p, "Center");
#Page 294
Change drawPolyLine to drawPolyline
#Page 303-304, FillPoly.java
Remove the last line of page 303 (int dx = ...) and the first line of page 304 (int dy = ...).
Page 309
Change MediaTracker tracker = new MediaTracker(); to MediaTracker tracker = new MediaTracker(this);
Page 312
Remove "scaled" from 3rd line.
*Page 316
Change "and it impossible to change the events a Visual Basic component responds to" to "and it is impossible to change the events a Visual Basic component responds to"
Page 321
In Figure 8-2, the method name getObject should be changed to getSource.
Page 321
Change "Inside that method, the panel is accessed as the this pointer. " to "Inside that method, the panel is accessed as the thisreference. "
#Page 322
Change "The simple program in Exercise 8-1" to "The simple program in Example 8-1"
*Page 325
Change "..so that clicking the button-schanges the look and feel" to "..so that clicking the buttons changes the look and feel"
#Page 328
Change "class Terminator implements" to "class Terminator implements WindowListener"
*Page 332
Change "so there is no benefit in having adapter class for these interfaces" to "so there is no benefit in having adapter classes for these interfaces"
Page 333
Change "ActionEvent (..., selecting a list item, ...)" to "ActionEvent (..., double-clicking a list item, ...)"
#Page 337
In the focusLost method, add a space before the && , i.e. change : ccField&& !evt.isTemporary() to ccField && !evt.isTemporary() .
Page 340
Change capitalization of keyEvent.VK_RIGHT to KeyEvent.VK_RIGHT
*Page 342 Sketch.java
Replace
int modifiers = evt.getModifiers();
int d;
if ((modifiers & InputEvent.SHIFT_MASK) != 0)
with
int d;
if (evt.isShiftDown())
#Page 346
Remove | from middle of "con-|stants"
Page 349
Replace the blank third line of the mouseClicked method with
current = find(x, y);
#Page 359
(bottom) Change "create a KeyStroke object that encapsulate a key stroke." to "creates a KeyStroke object that encapsulate s a key stroke."
Page 360
In the description of the getModifiers method, change CONTROL_MASK to CTRL_MASK
Page 384
Change contentPane.add(yellowButton, "South")); to contenetPane.add(yellowButton, "South");
*Page 394
Replace "(em-dash)3" with "--3"
Page 406
Change "The getSelectionStart and getSelectionEnd methods return the current selection." to The getSelectionStart and getSelectionEnd methods return thestart and end of the current selection."
#Page 407 TextEditTest.java
Change setSize(300, 300) to setSize(500, 300)
*Page 412
Change
small = new JRadioButton("Small", false);
medium = new JRadioButton("Medium", true);
to
smallButton = new JRadioButton("Small", false);
mediumButton = new JRadioButton("Medium", true);
Change
group.add(small);
group.add(medium);
to
group.add(smallButton);
group.add(mediumButton);
*Page 413
Change "Interestingly enough, by default, the action command of a well be an oversight by the Swing implementors.)" to "Interestingly enough, by default, the action command of a radio button is its text label, but the action command of its model is null. (This may well be an oversight by the Swing implementors.)"
Page 415
Change "the label on the check box" and "the initial state of the check box." to "the label on the radio button" and "the initial state of the radio button."
Page 419
In fourth static TitledBorder createTitledBorder, change "... (Border String title,..." to "...(Border border , String title,..."
#Page 419
In last createTitledBorder method: Change "TitleBorder.LEFT , TitleBorder.CENTER, TitleBorder.RIGHT" to " TitledBorder.LEFT, TitledBorder.CENTER , TitledBorder.RIGHT". Change "one of ABOVE_TOP , TOP, BELOW_TOP, ABOVE_BOTTOM, BOTTOM , BELOW_BOTTOM" to "one of the TitledBorder constants ABOVE_TOP, TOP , BELOW_TOP , ABOVE_BOTTOM , BOTTOM, BELOW_BOTTOM" and clean up the justification.
Page 420
Change "color, shadow colors for 3D effect" to "highlight , shadow colors for 3D effect".
#Page 427
Change "you'll find the details in the code listing in Example 9-8" to "you'll find the details in the code listing in Example 9-9 ".
*Page 433 and Page 435 ListRenderingTest.java
In paintComponent, add a call to super.paintComponent like this:
public void paintComponent(Graphics g)
{ super.paintComponent(g);
Font font = (Font)value;
*Page 445 ColorSelect.java
Change
Frame f = new ColorSelect
to
JFrame f = new ColorSelect
*Page 447
Change "To take advantage of this feature, simply make an object of type JScrollPane. Then supply the component to be viewed as the first argument in the constructor." to "To take advantage of this feature, simply make an object of type JScrollPane. Supply the component to be viewed as the first argument in the constructor."
*Page 447
Change
JScrollPane sp = new JScrollPane(viewedComponent,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER,
to
JScrollPane sp = new JScrollPane(viewedComponent,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS
(that is, switch the last two lines)
Page 447
Change "Example 9-12 shows..." to "Example 9-13 shows..."
Page 455
The name of the second constructor in the API section should be changed from ScrollPane to JScrollPane.
*Page 463 Figure 9-26
The class JMenu, which extends JMenuItem, is missing.
Page 472 BoxLayoutTest.java
Change new JTextField() to new JTextField(10) (2x). Note: Also see the FAQ regarding this program.
Page 476
Change "see the listing in Example 9-14" "see the listing in Example 9-17"
#Page 476
"In the grid bag layout for Figure 9-29" should refer to "Figure 9-31"
Page 479 FontDialog.java
Change add(sample, gbc, 0, 3, 4, 1); to add(sample, gbc, 0, 3, 3, 1);
*Page 481
Change "You need to override the following five functions." to "You need to override the following five methods."
Page 483
Change maxComponentHeight = Math.max(maxComponentWidth,d.height); to maxComponentHeight = Math.max(maxComponentHeight ,d.height);
Page 488
Change menuBar.addMenu(editMenu) to menuBar.add(editMenu) .
Page 489
Change
new Object[]
{ "Insert",
"Overtype",
"Read only"
}
to
new Object[]
{ "Read only",
null,
"Insert",
"Overtype"
}
Page 491
Change public void actionPerformed(Event evt) to public void actionPerformed(ActionEvent evt)
Page 493
Change "... by default, the menu items are placed to the right..." to "... by default, the menu icons are placed to the left ..."
Page 493
Change "If you prefer the icon to be placed on the left" to "If you prefer the icon to be placed on the right"
Page 506
There is a formatting glitch at the bottom of the page. "Any other object:" should be a new entry in the left hand column, and "apply toString and show the resulting string" should be the matching entry to the right.
#Page 507
Change "You can see these options by running the program in Example 9-19" to "You can see these options by running the program in Example 9-20".
Page 508
Change
// import javax.swing.*;
// import javax.swing.border.*;
import com.sun.java.swing.*;
import com.sun.java.swing.border.*;
to
import javax.swing.*;
import javax.swing.border.*;
*Page 510 OptionDialogTest.java
Remove the line gridPanel.add(showPanel);
#Page 517
Change public AboutDialog(JFrame parent) to public AboutDialog(JFrame parent) extends JDialog
Page 517
Let's try that again...Change
public AboutDialog(JFrame owner) extends JDialog
{
. . .
}
to
public class AboutDialog extends JDialog
{
public AboutDialog(JFrame owner)
{
. . .
}
}
*Page 520 and Page 523 DataExchangeTest.java
In showDialog, change transfer.password = password.getText(); to transfer.password = new String(password.getPassword ());
*Page 523 DataExchangeTest.java
Change JTextField password; to JPasswordField password;
Page 525
Change d.getSelectedFile().getName() to d.getSelectedFile().get Path()
#Page 526
Change public class GifFilter implements FileFilter to public class GifFilter extends FileFilter
Page 526
Change d.setFileFilter(new FileFilter to d.setFileFilter(new FileFilter()
Page 544
At top of page change to "...calculator application from Chapter 9"
Page 544
Change "We eliminated...,changed the panel class to an applet class, ..." to "We eliminated..., changed the frame clas to an applet class,..."
Page 547
Change "Unfortunately, the HTML tags that will be created by the Java Plug-In ..." to "Unfortunately, the HTML tags that will be created by the HTML converter..."
*Page 551
Change "1.2 features" to "Java 2 features"
Page 553 first code section
Change
...a calculator here>
    
to
...a calculator here></APPLET>
Page 554
Change
<EMBED TYPE="application/x-java-applet;version=1.1"
PLUGINSPAGE="http://java.sun.com/products/plugin/1.1
/plugin-install.html"
CODE="CalculatorApplet.class"
CODEBASE="MyApplets"
WIDTH=100
HEIGHT=150>
<PARAM NAME="Font" Value="Helvetica">
</EMBED>
to
<EMBED TYPE="application/x-java-applet;version=1.2"
PLUGINSPAGE="http://java.sun.com/products/plugin/1.2 /plugin-install.html" CODE="CalculatorApplet.class" CODEBASE="MyApplets" WIDTH=100 HEIGHT=150 Font="Helvetica">
</EMBED>
Change "Just change APPLET to EMBED and add . . ." to "Just change APPLET to EMBED, change the PARAM tag attributes to attributes of the EMBED tag and add . . ."
Page 560
Change “the calculator application from Chapter 7” to “the calculator application from Chapter 9”
Page 566
Change “You can tell the browser to show the applet in another window” to “You can tell the browser to show the document in another window”
Page 596
Change
done = true;
to
show error dialog
Page 596
At the end of the first paragraph in item 2., remove ", and then exits the method".
Page 604
Change AccessibleObject.setAccessible(fields, true) to AccessibleObject.setAccessible( f, true).
#Page 610
"Example 11-5" should be "Example 11-4"
#Page 624 last line
Change "byte" into "stream"
Page 630
Change byte b = fin.read(); to byte b = (byte)fin.read();
Page 637
Change "The same is true for the write method." to "Similarly, the write method accepts both a RandomAccessFile and a DataOutputStream."
Page 649
Change
zout.putNextEntry(zout);
send data to ze;
to
zout.putNextEntry(ze);
send data to zout;
Page 666 ObjectFileTest.java
Change class ObjectFileTest to public class ObjectFileTest
#Page 667
Change "ObjectInputStream(new FileInputStream("test1.dat"));" to "ObjectInputStream(new FileInputStream("employee.dat")); "
Page 694
Change the explanation of createNewFile() to:
atomically makes a new file whose name is given by the File object, if no file with that name exists. That is, the checking for the file name and the creation are not interrupted by other file system activity. Returns true if the method created the file.
Page 698
Change chapter number for super from 4 to 5.
Page 700
Change "<b>...</b> bold for bold" to "<b>...</b> for bold"
Page 708
Change "CoreJavaBook\ch2\ImageViewer" to "CoreJavaBook\v1ch2\ImageViewer".
Page 733
In index change page number of super (keyword) from 69 to 165.

Volume 2 {short description of image}

Page 17
Change { in bold to { in plain text
Page 34
Change laload to iaload
Change lsub to iadd
Change lastore to iastore
Page 38 first paragraph
Change "You do so by putting the both the test and the transfer action..." to "You do so by putting both the test and the transfer action..."
Page 48 line 20
Change resume to requestResume
Page 54
Change paintComponent(Graphics g) to paint(Graphics g)
Page 55 Animation.java
The applet doesn't display the rotating globe. Remedy: Change paintComponent to paint. (Alternatively, it would be a good idea to insert a frame inside the applet's content pane. But that change will have to wait until the 5th edition.)
Page 56
Change Timer(listener, 1000) to Timer(1000, listener)
Page 60 TimerTest.java
Change private final int LOCAL = 16; to private static final int LOCAL = 16;
Page 61 line 3
Change "...to a listener" to "...to a listener."
Page 66:
Change
EventQueue.invokeLater(new Runnable()
{ public void run()
{ label.setText(percentage + "% complete");
}
}
to
EventQueue.invokeLater(new Runnable()
{ public void run()
{ label.setText(percentage + "% complete");
}
});
Page 81
In the addAll method, change Iterator iter = iterator(); to Iterator iter = from.iterator(); and add ; to the end of return modified.
Page 81
Change "(such as add and iterator )" to "(such as size and iterator)"
Change public abstract boolean add(Object obj); to public abstract int size();
Page 83
Change
Object remove()
removes and returns the last visited object.
to
void remove()
removes the last visited object.
Page 85
Change "The LinkedList class implements the Collection interface." to "The LinkedList class implements the List interface."
Page 102 in the paragraph before Example 2-3:
Change "the default sort order of item objects" to "the default sort order of Item objects"
Page 103
Change if (getClass() == other.getClass()) to if (other != null && getClass() == other.getClass())
Page 105 in the second code section
Change
String s = "1411-16-2536"
to
String s = "987-98-9996"
Page 110 first paragraph
Change "and the key and associated values are removed..." to "and the keys and associated values are removed..."
Page 111
Change "sublasses" to "subclasses" (unless you are Irish)
Page 111
In the API note for java.util.TreeMap, change “tree set” to “tree map” (2x)
Page 112
Change
boolean put(object key, object value) 
to
Object put(object key, object value)
Page 112
Change "There are two fundamental interfaces for containers::" to "There are two fundamental interfaces for collections:"
Page 113
Change "to obtain views of subsets of the containers." to "to obtain views of subsets of the collections."
Page 114
Change AbstractCollecton to AbstractCollection in Figure 2-10.
Page 116
Change map = Collections.synchronizedMap(hashMap); to Map map = Collections.synchronizedMap(hashMap);
Page 116 end of second paragraph
Change "For example, the static synchronizedMapclass in the Collections class..." to "For example, the static synchronizedMapmethod in the Collections class..."
Page 124
Change if (largest.compareTo((Comparable)v.get(i)) <0) to if(largest.compareTo(vector.get(i))<0)
Change largest = v.get(i); to largest =(Comparable)vector.get(i); 
Page 124
Change largest = next; to largest = (Comparable)next;
Page 125
Change public compare(Object a, Object b) to public int compare(Object a, Object b)
Page 131
Change items.set(i,comboBox.getItemAt(i)); to items.add(i,comboBox.getItemAt(i));
Page 132
Change ArraySet streams to ArrayList streams
Page 142
Change "clears all bits in this bitset that are set in the other bit set.." to "clears all bits in this bitset that are set in the other bit set."(delete one period)
Page 136
Change "background color" to "foreground color"
Page 151
Add ( to BufferedReader in = new BufferedReader (new InputStreamReader(s.getInputStream())); in middle of page.
Page 151
Change "we are importing the java.net class" to "we are importing the java.netpackage"
Page 151
Change "...that you can use like any other file" to "...that you can use like any other stream"
Page 152
Change String line to String line;
Change while((String line = in.readLine()) != null) to while((line = in.readLine()) != null)
Page 154 SocketOpenerTest.java
Remove the semicolon at the end of the program
Page 154
Change getBytes to getAddress (2x)
Page 166 first paragraph
Change "and to get a glimpse what goes on..." to "and to get a glimpse of what goes on..."
Page 166
After "Transport.send(message);", change "multiple recipients, handling attachment, and so on." to "multiple recipients, handling attachments , and so on."
Page 173
Change "then the user can receive output from this URLConnection " to "then the user can send output to this URLConnection "
Page 174
Change
InputStream openInputStream()
OutputStream openOutputStream()
to
InputStream getInputStream()
OutputStream getOutputStream()
Page 175 second to last paragraph:
Change "(CGI stands for Common Gateway Interface)." to "(CGI stands for Common Gateway Interface.) "
Page 177
Add / to URL url=new URL("http:/host/scipt") so that it's "http://..."
Page 180
Change "call doOutput(true)" to "call setDoOutput(true)"
Page 183
Change "how to read data from" to "how to send data to"
Page 185
Change
weather.setFont(new Font("Courier", Font.PLAIN, 12));
to
weather.setFont(new Font("Courier", Font.PLAIN, 12));
weather.setEditable(false);
Page 185
Change
// Add the report button
contentPane.add(new JScrollPane(weather),BorderLayout.CENTER);
to
contentPane.add(new JScrollPane(weather),BorderLayout.CENTER);
// Add the report button
Page 189
Change "Figure 3-13: Applet security disallows connection to third party" to "Figure 3-13: Applet security disallows connection to a third party"
Page 199
Change step 1, to "Download the JavaServer Web Development Kit from..."
Page 200 second line
Change javac -classpath \jswdk\lib\servlet.jar;. proxySvr.java to javac -classpath \jswdk\lib\servlet.jar;. ProxySvr .java
Page 200 after numbered list
Change "Your browser needs a Java 2 plugin." to " Your browser needs a Java 2 Plug-in."
Page 221
Change float price = rs.getDouble("Price"); to double price = rs.getDouble("Price");
Page 230
Change stmt.commit() to con.commit()
Page 233
Change AND BooksAuthors.Author = Authors.Author to AND BooksAuthors.Author_Id = Authors.Author_Id
Page 233
Change
class QueryDB extends Frame
{
    QueryDB()
to
class QueryDBFrame extends JFrame
{
    public QueryDBFrame()
Page 240
Change
Label l = new Label (columnName);
TextField tf = new TextField (columnWidth);
to
JLabel l = new Label (columnName);
JTextField tf = new TextField (columnWidth);
Page 271
Change java ProductClient -Djava.security.policy=client.policy at top of page to java -Djava.security.policy=client.policy ProductClient.
Page 277
Change "the client cannot return a string stub object." to "the server cannot return a string stub object." 
Page 280
Change "the clear operation serves no useful purpose" to "the reset operation serves no useful purpose"
Page 280
ProductImpl.java implementation is incorrect. See the CD for the correct program. (Or ignore the image file field.)
Page 284 WarehouseServer.java
Remove the line throws RemoteException after public static void fillWarehouse(WarehouseImpl w)
Page 312
Add a period after "is bound to the given name"
Page 312
Change "Example Example 5-19" to "Example 5-19"
Page 313
Change "Next, you need write" to "Next, you need to write"
Page 314
Change "6. Run the client(java EnvClient)" to "6. Run the client(SysPropClient)"
Page 322 in the UML diagram
Change the solid line from DefaultTreeModel class to TreeModel class to be a dashed line
Page 357
In the API explanation for method valueForPathChanged, change "object the replacement value returned by the editor" to "newValue the replacement value returned by the editor"
Page 378
Change "That method is called when the tree needs to draw a cell." to "That method is called when the table needs to draw a cell."
Page 392 first bullet paragraph
Change "parent the component over which to pop up the dialog" to "component the component over which to pop up the dialog"
Page 424 in the API explanation:
Change "construct a horizontal slider with the given direction, minimum, maximum, and initial values" to "construct a horizontal slider with the given direction, minimum, and maximum"
Page 453
Change
 while (next != i && frames[next].isIcon())
next++;
to
 while (next != i && frames[next].isIcon())
next = (next + 1) % frames.length;
Page 461
Change "Use the setClip" to "Use the clip"
Change "Use the setTransform" to "Use the transform"
Page 472
Change second path.append(r, false); to path.append(r, true);
Page 494
Change new BufferedImage(width,height,TYPE_INT_ARGB); to new BufferedImage(width,height,BufferedImage.TYPE_INT_ARGB);
Page 499/500
Change "The graphics context will apply the transformations in the order in which you supplied them." to "The graphics context will apply the transformations in the opposite order in which you supplied them. That is, the last transformation that you supply is applied first." Change
g2.translate(-x, -y);
g2.rotate(a);
g2.translate(x, y);
to
g2.translate(x, y);
g2.rotate(a);
g2.translate(-x, -y);
Change "The first transformation . . ." to "The last transformation (which is applied first) . . ." Change "The third transformation . . ." to "The final transformation . . ."
Page 521
Change VALUE_ANTIALIAS_ON to RenderingHints.VALUE_ANTIALIAS_ON , VALUE_TEXT_ANTIALIAS_ON to RenderingHints.VALUE_TEXT_ANTIALIAS_ON (each 2x)
Page 563 in the note
Change "RFC (Request for Comment)..." to "RFC (Request for Comments)..."
Page 565 bottom of page
Change
DataFlavor flavor = DataFlavor.stringFlavor;
if (selection.isdataFlavorSupported(flavor))
{ try
{ String text = (String)(selection.getTransferData(flavor);
do something with text; } catch(Exception e) { ... } }
to
DataFlavor flavor = DataFlavor.stringFlavor;
if (contents.isdataFlavorSupported(flavor))
{ try
{ String text = (String)(contents.getTransferData(flavor));
do something with text; } catch(Exception e) { ... } }
Page 567
In the copy method, change if (text.equals("")) to if (text == null)
Page 616
Change "...crosshair)." to "...crosshair.)"
Page 622
Change "automatically displays the bean" to "automatically displays the image"
Page 628 in the Tip
Change public void setProp(String p) { prop = p; ) to public void setProp(String p) { prop = p; }
Page 633/634
The grey java.beans.PropertyChangeEvent API bar needs to be moved above the PropertyChangeEvent bullet.
Page 634 in the first API explanation
Change "Object the bean source for the property" to "source the bean source for the property"
Page 634
Change the first occurrence of void removePropertyChangeListener(PropertyChangeListener listener) to void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
Page 647
In method run, change while (!interrupted()) to while (!Thread.interrupted())
Page 667
Change "draw the value." to "draw the value" (without period)
Page 705
Remove the comma after The Code Breakers
Page 715
Change "multicas;t" to "multicast;"
Page 721
Change byte data[] to byte[] data
Page 726
Change "to all files the directory" to "to all files in the directory"
Page 720
In Method column of Table 9-1:
Change SecurityManager to checkPermission
Page 727
Change "Here is an typical use" to "Here is a typical use"
Page 738 last sentence
Change "The delete the..." to "Then delete the..."
Page 742
Change "sets the security for remainder of this application" to "sets the security for the remainder of this application"
Page 745
Change "If he had a been the proud owner" to "If he had been the proud owner"
Page 745
Change "Network and Internetwork Security" to "Cryptography and Network Security." "Network and Internetwork Security" is out of print.
Page 775
Change "Netscape 5" to "Netscape 6"
Page 777 in the first note
Change "We recommend that you don't touch to the cacerts file" to "We recommend that you don't touch the cacerts file"
Page 786
Change "returns all arrays that the DateFormat class can handle" to "returns all locales that the DateFormat class can handle"
Page 799
In the DateFormat API note, change the first getDateTimeInstance to getTimeInstance
Page 802
Change "is appropriate for most use" to "is appropriate for most uses"
Page 804
Change string.add("=ngstrom") to string.add("Ångstrom")
Page 808
Change " The quick, brown fox" to "The quick, brown fox"
Page 820
Change "classes that were described in Chapter 1" to "classes that were described in Volume 1 Chapter 12"
Page 821
Change InputStreamReader = to InputStreamReader in =
Page 821
Change "but as you saw in Chapter 1" to " but as you saw in Volume 1 Chapter 12 "
Page 821
Change "as you saw in Chapter 1" to "as you saw in Volume 1 Chapter 12" "
Page 826
Change "The Java programming language provides it" to "The Java library provides it".
Page 832
Change "for the entire duration of the application" to "for the entire duration of the applet"
Page 874 lines 10, 11 from top
Change GetObjectArray to GetObjectArrayElement and SetObjectArray to SetObjectArrayElement

Thanks to Kjell Ahlstedt, Knut Åkesson, Lynn Alford, Tony Alicea, Alvaro Antunes, Likun Bai, Steve Bang, Robert Benea, Mark Berkwitt, Joe Bianco, David Blankley, Mike Bopf, Fabiano Bortolotti, George Bradt, David Brown, Jon Byrd, Homer Carlisle, Scott Carpenter, Jose Castellano, Lila Chan, Albert Cheng, Christos Chryssochoidis, Frank Chu, David Cook, George Curry, Brahma Dathan, Geoff Davis, Joe Demasco, Behr de Ruiter, Aniruddha Desai, Ed Deveaux, Judah Diament, Eric Dickinson, Gerwin van Dijken, Howard Dolginoff, John Dougherty, Daniel Dvorak, Judy Enos, Jenn Ferguson, Michael Flanagan, Vitali Fridman, William Gandler, Sam Ganzman, Mark Garratt, Stephen Glow, Bret Goen, John K Gotwals, Michael Grahn, Simon Grönlund, James Guerin, Lev Gurevich, Truls Haaland, Nik Hagan, Margery Harrison, Luc Hermans, Jeff Hildebrand, David Hills, Susan Hilt, Ron Hofman, Ajit Jaiswal, Loic Julien, Praful Kapadia, Chris Kelly, Craig Kemple, Thomas Klimpel, Greg Knight, Eva Kocsis, Greg Kostal, Jim Kovacs, Per Kromann, Bill Lee, Mali Lev-Ram, Mark Lindberg, Emilio Luna, Mike Luscic, Naz Madhani, Jonathan Mann, Dan Marion, François Martin, Sunil Matta, David Mediavilla, Ross Mehlman, Marlene Miller, Olga Mironova, Manoranjan Mishra, Bhadresh Modi, Joe Mundi, Alan Murray, Steve Nicodemus, James Olson, Vince O'Sullivan, Scott Palmer, Ron Parker, Warren Patterson, Marcia Perry, Ajay Pherwani, Vandana Pherwani, Yuriy Podoshev, David Prowak, Boris Pulatov, Suryanarayanan Ramamurthy, Steve Rank, Stuart Reges, Fred Romeo, Anubhav Saini, Art Salwin, Syed Sarwar, Yvon Sauvageau, Volker Schildwach, David Schonberger, Ben Schwarz, Seshadri, Paul Sevinc, Nishith Shah, Rayees Shamsuddin, Peter Shannon, Roman Smolgovsky, Peter Snow, Paul Stanford, Edmund Stephen-Smith, David Sousa, Bruce Strong, Thomas Subias, Isak Swahn, Andrew Swartzbaugh, Kenya Tanaka, Dave Taenzer, Benjamin Townsend, Richard Trahan, Tis Veugen, Ray Wagner, Guangde Wang, Clifford Ward, Jason Warlikowski, Yimin Wei, Jonathan White, Michael William, Jesse Wong, Dan Wolf, Curt Wu, Rebecca Xue, Sugiarto Yamanto, Gary Yee, Michael Zand, Hector Zendejas, Dongdong Zhang, Jian Zhang, Wei Zhang, Christian Zmasek,Werner Zsolt, and a number of anonymous contributors for their bug reports!

Last Modified: 2004-03-13


Back to the Core Java page.