Updates: Fourth Edition

Below you will find the updates and bug reports for Volumes 1 and 2 of Core Java, Fourth Edition (Java 2).

Notations Used in the Bug Report Listing
Notation Meaning
2p fixed in second printing
3p fixed in third printing

You can identify which printing of the book you have by opening to the copyright page and locating the row of descending numbers beginning with the numeral 10. The lowest number in that row identifies the printing of the book.

Volume 1

2p Page 2 second paragraph
Change "due its portability" to "due to its portability"
2p Pages 3 (2x), 16 (2nd occurrence), 17, 39, 261, 265 (2x), 540
Change "Java 1.2" to "Java 2"
3p 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)".
3p Page 16 first line
Add a period after "canvas" and before the closing parenthesis.
2p 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."
3p 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..."
3p Page 22 last paragraph
Change "an excellent shareware programming editors" to "an excellent shareware programming editor".
3p 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..."
2p 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"
3p Page 26
In the caution warning, replace "CLASSES.ZIP in the lib directory" with "rt.jar in the \jdk\jre\lib directory".
3p 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()
2p 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");
3p 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".
3p Page 46
Remove unmatched ending ) at the end of the VB Note.
2p 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..."
2p Page 55
Change "byte -> short -> int -> long -> float -> double" to "byte -> short -> int -> long -> float -> double and char -> int"
3p 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".
2p 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."
3p 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));
2p 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)
2p Page 72
Change String s = new Format.form to String s = new Format
3p 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)
3p 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 .)
3p Page 79 Retirement.java
Change Your can retire in to You can retire in.
2p Page 87
In the last paragraph, change "parameters" to "arguments" (2x)
2p 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)"
2p 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."
3p Page 93
The last value of Figure 3-8 should be 12, not 13.
3p 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"
3p 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".
3p 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"
2p Page 112
Change "Universal Modeling Language" to "Unified Modeling Language"
Page 115
Change "(See Figure 4-6)" to "(See Figure 4-6.)"
3p 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"
3p 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"
2p 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

3p 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.
3p 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 ...".
3p 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.
2p Page 143
Change "This mechanism is never necessary and it is common" to "This mechanism is never necessary and it is not common"
3p 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."
3p 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".
3p 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."
2p Page 148 RandomIntGenerator.java
In the draw method, remove the line if (r > high) r = high;
3p Page 148 RandomIntGenerator.java
In the nextRandom method, remove the line if (pos == BUFFER_SIZE) pos = BUFFER_SIZE - 1;
2p Page 151 CardDeck.java
Change void play(int rounds) to public void play(int rounds)
3p 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)
3p 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."
3p 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"
3p Page 158
Change public void trustMe to public static void trustMe.
3p Page 160
Change public void CardDeck() { . . . } to public CardDeck() { . . . }
3p 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.

3p 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."
2p Page 180 MailboxTest.java
Change private final int MAXMSG = 10; to private static final int MAXMSG = 10;
2p 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."
3p 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".
2p 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 >.)
3p Page 187
Change "Use the addElement method" to "Use the add method".
3p Page 190
Change "Accessing Vector Element" to "Accessing Vector Element s"
2p Page 190, 198
Change "version 1.2" to "Java 2".
3p Page 191
Change "--see the next section)" to "--see the next section.)" (I.e., add a period before the closing parenthesis.)
3p 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).
3p 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 .)"
3p Page 196
Change ".doubleValue()" and "Double" to "doubleValue()" and "Double". (I.e. drop the unnecessary period and fix up the fonts.)
3p Page 197
In the note, change IntegerHolder to IntHolder.
Page 199
Change "equivalent of the number object, ..." to "equivalent of the Number object, ..."
2p 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..."
3p 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.
3p 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."
3p Page 214 and ObjectAnalyzerTest.java
The line: r += val.toString; should be: r += val.toString ();
Page 216 line 1
Remove the period after AccessibleObject
3p 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"
3p 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 .
3p 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).
3p Page 227
Change "Example 6-1: EmployeeSortTest" to "Example 6-1: EmployeeSortTest .java"
3p 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.)"
2p Page 236
Change
e.hireDay = hireDay.clone();

to:

e.hireDay = (Day)hireDay.clone();
Page 238
Change TimerListener listener; to private TimerListener listener;
2p 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."
3p 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."
3p 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
2p Page 265 (2x)
Change "1.2" to "Java 2"
Page 265
Change "Note that does not..." to "Note that this does not..."
3p Page 266
JFrame = new FirstFrame(); should read: JFrame frame = new FirstFrame();
3p 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 ".
3p 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"
3p 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)
2p 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"--you 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.)

2p 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".
2p 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");
3p Page 294
Change drawPolyLine to drawPolyline
3p 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.
2p 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. "
3p Page 322
Change "The simple program in Exercise 8-1" to "The simple program in Example 8-1"
2p Page 325
Change "..so that clicking the button-schanges the look and feel" to "..so that clicking the buttons changes the look and feel"
3p Page 328
Change "class Terminator implements" to "class Terminator implements WindowListener"
2p 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, ...)"
3p 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
2p Page 342 Sketch.java
Replace
int modifiers = evt.getModifiers();
int d;
if ((modifiers & InputEvent.SHIFT_MASK) != 0)

with

int d;
if (evt.isShiftDown())
3p Page 346
Remove | from middle of "con-|stants"
Page 349
Replace the blank third line of the mouseClicked method with
current = find(x, y);
3p 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");
2p 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."
3p Page 407 TextEditTest.java
Change setSize(300, 300) to setSize(500, 300)
2p 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);
2p 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,..."
3p 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".
3p 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 ".
2p 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;
2p Page 445 ColorSelect.java
Change
Frame f = new ColorSelect

to:

JFrame f = new ColorSelect
2p 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."
2p 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.
2p 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"
3p 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);
2p 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.
3p 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.*;
2p Page 510 OptionDialogTest.java
Remove the line gridPanel.add(showPanel);
3p 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)
   {
      . . .
   }
}
2p Page 520 and Page 523 DataExchangeTest.java
In showDialog, change transfer.password = password.getText(); to transfer.password = new String(password.getPassword ());
2p Page 523 DataExchangeTest.java
Change JTextField password; to JPasswordField password;
Page 525
Change d.getSelectedFile().getName() to d.getSelectedFile().get Path()
3p 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..."
2p 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).
3p Page 610
"Example 11-5" should be "Example 11-4"
3p 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
3p 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

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 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 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 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 114
Change AbstractCollecton to AbstractCollection in Figure 2-10.
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 125
Change public compare(Object a, Object b) to public int compare(Object a, Object b)
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 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 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 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 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 230
Change stmt.commit() to con.commit()
Page 271
Change java ProductClient -Djava.security.policy=client.policy at top of page to java -Djava.security.policy=client.policy ProductClient.
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 472
Change second path.append(r, false); to path.append(r, true);
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 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 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, 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, Olga Mironova, 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: 2002-01-06.