Welcome to the Core Java Bug List
Second Edition Bugs
Bugs in both editions are denoted by page numbers p2/p1, where p2 is the
page number in the second edition and p1 the page number in the first edition.
- Page 6
- Change http://www.cs.princeton.edu/~felton to http://www.cs.princeton.edu/sip.
The link http://ferret.lmh.ox.ac.uk/~david/java/bugs/ is no longer available.
- Page 7
- Change http://java.sun.com:80/java.sun.com/sfaq/index.html to
http://java.sun.com/sfaq/index.html
- Page 9
- First paragraph: "third-part" should be "third-party"
- 25
- 'Go to \WIN95NT\WINEDITA' should be 'Go to \WIN95NT\WINEDIT\WINEDITA'.
- Page 25
- There is no separate doc directory. The documentation for RMI and
JDBC has been integrated into the class tree. There is no api
directory either. JavaSoft didn't want us to distribute it. The same information
is available, in more convenient from, in the class tree extracted with javadoc.
- Page 29/29
- Change java welcomeapplet.java to javac
welcomeapplet.java.
- Page 39/38
- Change "For example, for WinEdit, chose Project|Compile, then chose
Project|Run." to "For example, for WinEdit, chose Project|Compile,
then chose Project|Execute."
- Page 52
- Eliminate: "In fact, comments do not nest in Java." This should
be a note at the end of the "Comments" section, as it was in the first
edition.
- Page 62/60
- Change int thirdBit to int fourthBitFromRight.
- Page 74/72
- The second box of the graph should read "balance = (balance+payment)*(1+interest)"
- Page 74/72
- The "A" in "A while loop tests at the top"
should not be in the Courier font.
- Page 81/80
- The Format class on the CD ROM has two bugs. Formatting the most extreme
negative number (-9223372036854775808L) prints with 2 leading minus signs. And
printing 0 with a %e or %g format does not work. These are fixed in
Format.java
- Page 85/83
- Change "In our case, since the method belongs to the lotteryOdds
class" to "In our case, since the method belongs to the LotteryOdds
class"
- Page 106/104
- Date.parse returns a long, not a void (the
number of milliseconds since 1/1/70 00:00 GMT).
- Page 111/108
- Change: "Please enter the month..." to "Please enter the
month you were born, ..."7
- Page 112/109
- Change "we check the month (d.month())" to "we
check the month (d.getMonth())"
- Page 118
- A constructor is always called with the new keyword." newshould
be in Courier font.
- Page 136/130
- Reverse order of "c:\java\lib\corejava\Console.class" and "c:\java\lib\java\util\Console.class"
- Page 147/143
- Remove "We did that in the sample code of the preceding section".
- Page 164/160
- Change "So the //now what comment in..." to "So
the //now what? comment in..."
- Page 171/167
- Change "Probably the most commonly used method of getClass"
to "Probably the most commonly used method of the class Class"
- Page 211/207
- "draws an image" and "draws a scaled image" should be
interchanged
- Page 229/225
- Change setTitle("Panel test") to setTitle("PanelTest")
- Page 258
- In figure 7-11, remove the arrows TextComponent -> ScrollBar -> List
to Label -> Choice -> Checkbox -> Canvas -> Button. (This bug won't
die--it was fixed in the second printing of the first edition, but it reemerged
in the second edition.)
- Page 267/263
- Replace new GridLayout(5,4) with new GridLayout(4,4)
- Page 281/277
- Replace "You will need to tell it the name of the parent window"
with "You will need to supply a reference to the parent window".
- Page 287/283
- change "in the processResults method" to "in the
processResult method"
- Page 303/299
- Both the method mouseMove() and mouseDrag() are missing
a return true statement.
- Page 303/299
- In mouseDrag, replace draw(current) with draw(g,
current) (2x)
- Page 321/317
-
public void paint(graphics g)
Font f = new Font("System", Font.BOLD, 18);
{ ...
should be
public void paint(graphics g)
{ Font f = new Font("System", Font.BOLD, 18);
...
- Page 313/309
- The code right below the first and second paragraph, replace vert.setValue(horiz.getValue(),
d.height, 0, 400); with
vert.setValues(vert.getValue(), d.height, 0, 400);
- Page 327/323
- The CalculatorApplet.java program doesn't include the import corejava.*,
awt.*, and applet.* statements
- Page 328/324
- For the calculator applet, since the calculator doesn't have a % button,
the line in the calculate method
else if (op == "%") ...
is not needed.
- Page 357/353
- In Example 8-5: CrawlerApplet.java, in the method "search", the
line "AppletContext context = getAppletContext();" should be removed
- Page 376/372
- Replace Item i = (Item)itemsOrdered.removeElementAt(n);with itemsOrdered.removeElementAt(n);
(The method has no return value.)
- Page 381/377
- Change String s = "149-16-2536" to String s = "987-98-9996"
- Page 381
- The line e = staff.get(s); // gets harry
should read e = (Employee)staff.get(s); // gets harry.
- Page 410/404
- Change "The first four options are not appropriate" to "The
first three options are not appropriate"
- Page 410/404
- Change "But if the List class is part of the default package"
to "But if the LinkedList class is part of the default
package"
- Page 414/408
- The computation of the future values had the year and the interest rate
swapped. Replace balance[i][j] = futureValue(10000, 10 + 10 * i, 5 + 0.5 *
j); with balance[i][j] = futureValue(10000, 5 + 0.5 * j, 10 + 10 * i);
. The correct values of the table are then:
5.00% 5.50% 6.00% 6.50% 7.00% 7.50%
10 16470.09 17310.76 18193.97 19121.84 20096.61 21120.65
20 27126.40 29966.26 33102.04 36564.47 40387.39 44608.17
30 44677.44 51873.88 60225.75 69917.98 81164.97 94215.34
40 73584.17 89797.65 109574.54 133696.02 163114.11 198988.89
50 121193.83 155446.59 199359.55 255651.37 327804.14 420277.39
Jay Freedman, the discoverer of this bug, writes: "Interestingly, the
results of the erroneous version are similar to (at least, the same order of
magnitude as) those from the correct version. Beware of output that 'looks'
correct!"
- Page 458
- Change "or 1 to skip a number of bytes" to "or one to skip a
number of bytes"
- Page 535/531
- The program should use notifyAll instead of notify.
- Page 546/542
- Change g.drawImage(image, -i * imageHeight, imageCount, null)
with g.drawImage(image, 0, -i * imageHeight / imageCount, null)
- Page 546/542-543
- In the class definition(s) of Animation, replace extends
Runnable with implements Runnable
- Page 565
- Remove "public" from the front of "class ThreadedEchoHandler"
- Page 566/562
- Replace "client'(space)s" with "client's" and replace "Let'(line
break)s" with "Let's
- Page 575/571
- Change os.writeBytes to out.writeBytes (2x)
- Page 592
- Change San Jose to San+Jose
- Page 613
- There should be a comma after NUMERIC(m, n). The
or should not be set in Courier (2 x).
- Page 635
- The line
ResultSet rs = md.getTables("", null, "%", types)
should be changed to
ResultSet rs = md.getTables(null, "%", "%", types)
to be consistent with the sample program. Actually, these parameters
depend somewhat on your SQL server.
- Page 656
- Change the URL from "" to "rmi://"
with the 1.1 Beta version of RMI.
First Edition Bugs
- Page 24*
- Replace SET CLASSPATH=C:\java\lib;C:\CoreJavaBook with SET
CLASSPATH=C:\java\lib;.;C:\CoreJavaBook
- Page 25
- At the end of second paragraph, add "Use the File | OpenFile command
and select the file tree.html in the \java\api directory."
- Page 36*
- Replace Void Main with void main to match the figures
- Page 39
- Remove import java.net.*;
- Page 39
- Replace method "action" with
public boolean action(Event evt, Object arg)
{ if (arg.equals("Open"))
{ FileDialog d = new FileDialog(this,
"Open image file", FileDialog.LOAD);
d.setFile("*.gif");
d.setDirectory(lastDir);
d.show();
String f = d.getFile();
lastDir = d.getDirectory();
if (f != null)
image = Toolkit.getDefaultToolkit().getImage(lastDir + f);
repaint();
}
else if(arg.equals("Exit")) System.exit(0);
else return false;
return true;
}
where lastDir is a private variable of ImageViewer.
- Page 48
- Replace \CoreJavaBook\ch2\FirstSample directory. with \CoreJavaBook\ch3\FirstSample
directory.
- Page 49
- Replace "Thus you must have a main method (function) for your code to
compile." with "Thus you must have a main method (function) for your
code to execute."
- Page 53
- Replace "(7 significant decimal digits)" with "(6-7
significant decimal digits)"
- Page 59*
- Replace 3 !==7 with 3 != 7
- Page 60*
- Replace int thirdBit = (foo&8)/8: with int thirdBit =
(foo&8)/8;
- Page 60
- Replace "gives you a one if the third bit in the binary representation
of foo is on," with "gives you a one if the fourth bit from the right
in the binary representation of foo is on,"
- Page 62*
- Replace Expletive: with Expletive;
- Page 62
- Replace string greeting = "Hello"; with String
greeting = "Hello";
- Page 62
- Replace string s = greeting.substring(0, 4) with String s =
greeting.substring(0, 4);
- Page 63
- Replace int n = greeting.length() // is 5. with int n =
greeting.length(); // is 5.
- Page 66*
- Before "Once you have done this...", add
Be sure to add the
line
import corejava.*;
to every program that utilizes the Console class.
- Page 66*
- Add the line import corejava.*; before the line class ...
- Page 67*
- Add the line import corejava.*; before the line class ...
- Page 67*
- Replace "Your payment is" with "Your payment
is "
- Page 70
- The code should read
if (yourSales >= 2*target)
{ performance = "Excellent";
bonus = 1000;
}
else if (yourSales >= 1.5*target)
{ performance = "Fine";
bonus = 500;
}
else if (yourSales >= target)
{ performance = "Satisfactory";
bonus = 100;
}
else
{ System.out.println("You're fired");
}
- Page 71
- Remove C++ note. At the bottom of page 60, add
Selection Operator
The expression
condition ? e1 : e2
evaluates to e1 if the condition is true, to e2 otherwise. For example,
x < y ? x : y
computes the smaller of x and y.
- Page 71*
- Add the line import corejava.*; before the line class ...
- Page 73*
- Add the line import corejava.*; before the line class ...
- Page 75*
- Add the line import corejava.*; before the line class ...
- Page 76
- missing ; after Console.readInt()
- Page 80
- The Format class on the CD ROM has a bug--formatting 9.999 with "%.2f"
shows up as 9.00. This is fixed in Format.java
- Page 80*
- At the end of the sidebar, add
You must add the line
import corejava.*;
to every program that uses the Format class.
- Page 82*
- Add the line import corejava.*; before the line class ...
- Page 88*
- Add the line import corejava.*; before the line class ...
- Page 100
- Replace (Benjamin Cumming, 1994). with (Benjamin Cummings,
1994).
- Page 101
- At the end of 13th line(Now you can start applying AudioClip methods to
meow), add "(Actually, it is a little harder in Java to obtain a real
audio clip. Here we just use audio clips to introduce the typical object
notation.)"
- Page 103
- Replace Date preMillenium = new Date(1999,12,31); with Date
preMillennium = new Date(99,11,31);
- Page 103
- Replace Date preMillenium = new Date(1999,12,31,23,59,59); with
Date preMillennium = new Date(99,11,31,23,59,59);
- Page 105
- Add the line import java.util.*; before the line class ...
- Page 106
- There is a bug on the CD ROM in the default constructor of the Day class.
Here is the correct Day.java.
- Page 108*
- Replace Date with Day
- Page 109*
- Replace "make a Date object" with "make a Day
object"
- Page 111
- Replace { return name with { return name;
- Page 113*
- Replace "there are actually five access levels" with "There
are actually four access levels". (Note: The private protected
attribute is being withdrawn.)
- Page 113
- The instance fields in "Next, notice that there are three
instance fields" should be set in italics.
- Page 115
- Replace { return name with { return name;
- Page 116
- Replace "By the way, the function is called getName()
because it can't be called name()-" with "We could actually
call the method name(), although it would be confusing to have a
variable and a method that are called the same."
- Page 119
- Replace javac Mortgage with java Mortgage
- Page 120
- Remove package corejava;
- Page 121
- Replace Date today = new Date() with Day today = new Day()
- Page 121
- Replace Date preMillenium = new Date(1999,12,31) with Day
preMillenium = new Day(1999,12,31)
- Page 125
- At the bottom of this page, replace int cards; with private
int cards;
- Page 126
- Replace the code final public void fill() with the code at the
bottom of this page
- Page 143
- In the third paragraph, replace "However, staff[0] "forgets"
that it refers to a Manager and just considers itself as Employee
object." with "However, staff[0] is only considered to be an
Employee object by the compiler."
- Page 148*
- Replace "Java uses the inheritance syntax" with "Java uses
the cast syntax"
- Page 148
- Replace Manager* boss = dynamic_cast<Manager>(staff[1]);
with Manager* boss = dynamic_cast<Manager*>(staff[1]);
- Page 159
- Replace public string powerSource(PoweredVehicle); with public
String powerSource(PoweredVehicle);
- Page 162
- After the first paragraph, add "Tip: Instead of writing x.toString(),
you can write "" + x. That expression concatenates the
empty string "" with the string representation of x, that is,
x.toString(). This trick is a common idiom that you find in many java programs."
- Page 172*
- Remove the two sentences "To placate the C++ crowd... the same package".
- Page 172*
- Add a "C++ Note" icon to the paragraph that starts with "As
it happens, protected..."
- Page 172*
- Remove "3. visible to the class and all subclasses" and renumber
the remaining lines
- Page 177
- The second line in the second paragraph, replace "Alternative Window
Toolkit or AWT. Even though it is called the "alternative" toolkit,
you don't have ..." with "Abstract Window Toolkit or AWT. At one
point, it was called the "alternative" window toolkit, but you don't
have ... "
- Page 182
- Replace "How you handle an event is controlled by the handleEvent
method in the Event class." with "How you handle an event
is controlled by the handleEvent method in the Component
class."
- Page 183
- Replace "you need to override the paint method from the
Frame class" with "you need to override the paint
method from the Component class"
- Page 184
- In the second paragraph, replace "Not a Hello, World" with "Not
a Hello, World program"
- Page 184
- On the first line, replace "they are" with "it is"
- Page 186
- Replace Font(String name, Font property, int size) with Font(String
name, int property, int size)
- Page 187
- Replace cy += fim.stringWidth(s2); with cx +=
fim.stringWidth(s2);
- Page 195
- Replace int angle = 30;; with int angle = 30;
- Page 195
- Replace // opening angle of mouth with // half the opening
angle of mouth
- Page 197
- Replace void draw3dRect(...) with void draw3DRect(...)
- Page 200
- Add the following to the bottom of this page: "For the alternating
rule, a point is inside if an infinite ray with the point as origin crosses the
path an odd number of times."
- Page 201
- Replace int angle = 30;; // opening angle of mouth with int
angle = 30; // half the opening angle of mouth
- Page 204*
- Replace Toolkit.getDefaultToolkit.getImage(name) with Toolkit.getDefaultToolkit().getImage(name)
- Page 206
- Replace "The tiling occurs in the paint program." with "The
tiling occurs in the paint method."
- Page 209
- In the method paint, replace buffered_image with //
buffered_image
- Page 209
- On the top of the page, repalce for(int j = 0; j <= client_width /
image_width; j++) with
for(int j = 0; j <= client_height / image_height; j++)
- Page 209
- Replace "updates the component without erasing the current image."
with "updates the component unless overridden, it erases the screen area
and calls the paint method."
- Page 210
- Align text following dx and dy parameters
- Page 212*
- Replace "Since Frame (indirectly) extends" with "Since
Frame indirectly implements"
- Page 214
- replace java.awt.ImageObserver with java.awt.image.ImageObserver
- Page 218
- Figure 7-1 has wrong button labels. Figure 7-2 on page 221 has wrong button
labels too
- Page 219
- Replace yellowButton.setBackground(color.yellow); with yellowButton.setBackground(Color.yellow);
- Page 221
- Replace note on this page with "The add method belongs to the panel,
not the layout manager. But the layout manager needs to know about the added
items, and, more importantly, the layout directives (such as "North").
It needs that information so it can do the layout. Thus, whenever you add an
item to a container, the container passes on the item and any layout directives
to the layout manager."
- Page 223
- In the method "action", replace else return false; with
else return super.action(evt, arg);
- Page 227
- In the method "action", replace else return false; with
else return super.action(evt, arg);
- Page 231
- Replace int hours = Integer.parselnt(hourField.getText().trim())
with int hours = Integer.parseInt(hourField.getText().trim())
- Page 231
- In the method "action", replace else return false; with
else return super.action(evt, arg);
- Page 235
- Replace the method "getValue()" with
public int getValue()
{ int value;
try
{ value = Integer.valueOf(getText().trim()).intValue();
}
catch(NumberFormatException e)
{ value = 0;
}
return value;
}
- Page 243
- Replace Panel p; with
Panel p = new Panel();
p.setLayout(new FlowLayout());
- Page 250
- In the second paragraph, replace "parameters that take the number of
items ..." with "a parameter that takes the number of items ..."
- Page 254*
- Remove the arrows TextComponent -> ScrollBar -> List to Label ->
Choice -> Checkbox -> Canvas -> Button
- Page 254
- Replace panel.addLayout(new CardLayout()); with panel.setLayout(new
CardLayout());
- Page 260
- Replace 'and "Dialog".' with 'and "Preferences".'
- Page 260
- Replace
{ if(arg.equals("<"))
layout.next(cards));
else if ...
}
with
{ if(arg.equals("<"))
layout.previous(cards));
else if ...
}
- Page 262
- In the class SimpleDialog, remove
Panel p = new Panel();
p.add(new Button("OK"));
add("south", p);
- Page 264
- Add line import corejava.*; after the first line
- page 265
- Replace
if (op == "+") arg += n;
else if (op == "-") arg -= n;
else if (op == "*") arg *= n;
else if (op == "/") arg /= n;
else if (op == "%") arg %= n;
else if (op == "=") arg = n;
with
if (op.equals("+")) arg += n;
else if (op.equals("-")) arg -= n;
else if (op.equals("*")) arg *= n;
else if (op.equals("/")) arg /= n;
else if (op.equals("%")) arg %= n;
else if (op.equals("=")) arg = n;
- Page 266
- The text beneath figure 7-17, replace "the list box spans three
columns," with "the list box spans three rows,"
- Page 266
- The text beneath figure 7-17, replace "and the text field at the
bottom spans three fields." with "and the text field at the bottom
spans three columns."
- Page 267
- The second line from the end, replace "then the area never grows
beyond its initial size in that direction." with "then the area never
grows or shrinks beyond its initial size in that direction."
- Page 269*
- The program has a glitch in the constructor. It also doesn't actually show
the font in the sample line. The file
FontDialog.java fixes these blemishes.
- Page 270
- At the bottom of this page, replace int weightx, weighty with
double weightx, weighty
- Page 270
- Replace add(sample, gbl, gbc, 0, 3, 4, 1); with add(sample,
gbl, gbc, 0, 3, 3, 1);
- Page 271
- Add panel.add(ok); in front of the last line
- Page 275
- Remove if(n == 0) return;
- Page 278
- Replace if(arg.equals("OK")) dispose(); with if(arg.equals("Ok"))
dispose();
- Page 280
- In method "handleEvent", replace System.exit(0); with
dispose();
- Page 282
- Replace if(arg.equals("OK") with if(arg.equals("Ok")
- Page 282
- The first line, replace ConnectInfo defaults = new
UserInfo(defaultName, ""); with ConnectInfo defaults = new
ConnectInfo(defaultName, "");
- Page 287
- The top part of this page should read
FileDialog d = new FileDialog(parent, "Save note file", FileDialog.SAVE);
The third argument is either LOAD or SAVE. Set the directory.
d.setDirectory(".");
If you have a default file name that you expect the user to choose,
supply it here.
d.setFile(filename);
2. Then show the dialog box.
d.show();
- Page 287
- Replace if (d != 0) ... with if (filename != null) ...
- Page 287
- Add this line "This feature does not currently work." after the
line "sets the initial file mask for the file dialog."
- Page 290
- In the note, replace method with // method
- Page 297
- The Parameters for KeyUp, replace "key the key that is pressed"
with "key the key that is released"
- Page 304
- At the bottom of this page, replace public boolean handleEvent(Event
e) with public boolean handleEvent(Event evt)
- Page 306
- The method setPageIncrement(int l) should return void. Also at the end of
next paragraph, add "This method does not currently work correctly on all
platforms."
- Page 309
- In the first paragraph, replace WINDOW_MOVE with WINDOW_MOVED
- Page 309
- The code right below the first paragraph, replace Event.MOVE_EVENT
with Event.WINDOW_MOVED
- Page 319
- In the first paragraph, at the end of "You need to quit and restart
Netscape to reload the new version of the applet.", add "You can avoid
this problem by setting both the disk and memory cache size to 0, but then
performance suffers." (Note by Cay: I think this is an urban
legend--setting the cache size to 0 doesn't seem to work.)
- Page 324
- Replace
if (op == "+") arg += n;
else if (op == "-") arg -= n;
else if (op == "*") arg *= n;
else if (op == "/") arg /= n;
else if (op == "%") arg %= n;
else if (op == "=") arg = n;
with
if (op.equals("+")) arg += n;
else if (op.equals("-")) arg -= n;
else if (op.equals("*")) arg *= n;
else if (op.equals("/")) arg /= n;
else if (op.equals("%")) arg %= n;
else if (op.equals("=")) arg = n;
- Page 328
- The font used for the heading of the section on the NAME tag should be a
plain, upper-case italic, NOT a bold, mixed-case italic.
- Page 334
- Replace the second import java.awt.*;(on top and bottom part of
this page) with import java.applet.*;
- Page 334
- Replace <APPLET CODE="FontTestApplet.class WIDTH = 200
HEIGHT = 200> with
<APPLET CODE="FontTestApplet.class" WIDTH = 200 HEIGHT =
200>
- Page 336
- Move the instance variables at the front of the class "Chart" to
the end of the class. Also replace
double values[];
String names[];
String title;
with
private double[] values;
private String[] names;
private String title;
- Page 339
- Replace class CalculatorApplet extends Applet with class
PopupCalculatorApplet extends Applet
- Page 344
- Replace System.out.println(e.getClass().getName()); with System.out.println(a.getClass().getName());
- Page 345
- The second line from the end, replace "and you many not have seen the
relevant tags." with "and you may not have seen the relevant tags."
- Page 351
- Replace "As we said, we do not want to get into the details about
threads." with "As we said, we do not want to get into the details
about threads and the Runnable interface. See chapter 12 for more
information."
- Page 351
- Replace class CrawlerApplet extends Applet with class
CrawlerApplet extends Applet implements Runnable
- Page 351
- Replace method "start" with
public void start()
{ if(runner != null && runner.isAlive())
runner.resume();
else if(runner.isAlive())
runner.resume();
}
- Page 353
- In the method destroy(), replace runner.resume(); with runner.stop();
- Page 357
- In the middle of this page, replace "In this example, we just reuse
the retirement calculator." with "In this example, we just reuse the
calculator."
- Page 366
- In method action, remove the first "else if" clause.
- Page 370
- In the third paragraph, replace "This gives the user completely safe
set, append, and get array access methods." with "This
gives the user completely safe set, append, and get vector
access methods."
- Page 377
- Replace e = (Employee)employee.get(s); with e =
staff.get(s);
- Page 383
- Replace class PartNumber() with class PartNumber
- page 383
- Replace return 13 * description.hashValue() + 17 * version; with
return 13 * description.hashCode() + 17 * version;
- Page 384
- In the first paragraph, replace "then a test like the one below..."
with "then a lookup like the one below..."
- Page 386
- Replace two API descriptions elements() with Enumeration
elements()
- Page 393
- In the method HashSetTest(), "for" loop body name.addItem(f[i]);
needs to be indented
- Page 396
- Replace s1.reset(); with a.reset();
- Page 396
- Replace Employee e = (Employee)s1.currentElement(); with Employee
e = (Employee)a.currentElement();
- Page 397
- Remove the semicolon at the last line
- Page 403
- Comment in code saying "do something with ob;" should say "do
something with o;"
- Page 403
- Replace return current != 0; with return current != NULL;
- Page 404
- The call data.reset() in "remove()" of Queue is
unnecessary
- Page 404
- The private protected mechanism is no longer used in Java
- Page 413
- In the PascalCanvas constructor, the "if..else if..else.." block
in inner for loop need to be indented
- Page 423
- In C++ note, replace "The throws statement is the same as
..." with "The throws specifier is the same as ..."
- Page 435
- The last comment in the example code should be "// stack was empty"
- Page 437*
- Indent the paragraph starting with "For example, look at our Format.java
file..."
- Page 438
- Replace "Here is the code for the MessageCracker class"
with "Here is the code for the MessageCrackerTest class"
- page 439
- At the bottom of this page, in the end of "Netscape has a nice 'Java
Console' (available in the Options menu) that displays all the strings sent to
System.out.", add "(see figure 10-4)"
- Page 441
- Replace "Here is the code for the DebugWin class." with "Here
is the code for the DebugWinTest class."
- Page 443*
- The program listing is wrong. Please substitute the file
\CoreJavaBook\ch10\BuggyButtonTest\ButtonTest.java. Great--a bug in the
debugging chapter...
- Page 443
- In the method "action", replace else return false; with
else return super.action(evt, arg);
- Page 445
- In the "where" command description, replace "|" with "or"
- Page 448
- In the last paragraph, replace "Setting breakpoints in an action
statement works pretty well." with "Setting breakpoints in an action
method works pretty well."
- Page 456
- In the second paragraph, replace "FileInputStream and FileOutputStream
give you an input stream ..." with "FileInputStream and
FileOutputStream give you input and output streams ..."
- Page 458
- At the very bottom of this page, replace "Java has no method to
support that." with "Use writeChars for that purpose."
- Page 463
- Below the line java.io.PushbackInputStream, add line
. PushbackInputStream(InputStream in)
- Page 464
- Replace BufferedOutputStream(OutputStream in) with BufferedOutputStream(OutputStream
out)
- Page 464
- Replace BufferedInputStream(InputStream in, int n) with BufferedOutputStream(OutputStream
out, int n)
- Page 466
- In the API note for String nextToken(), replace "Throws a
NoSuchElementException if the are no more tokens." with "Throws
a NoSuchElementException if there are no more tokens."
- Page 466
- Replace "These three delimiters are used ..." with "These
four delimiters are used ..."
- Page 468
- Replace void readData(Employee[] e, DataInput in) with Employee[]
readData(DataInputStream in)
- Page 468
- In the third paragraph, remove "This also discards the prior contents
of e."
- page 468
- In the method "readData", replace e[i] = new Employee("",
0, null); with e[i] = new Employee();
- Page 469
- In the first "try" block, add os.close(); at the end,
in the second "try" block, add is.close(); at the end
- Page 469
- In the class "Employee", before the method print(), add public
Employee() {}
- page 471
- Replace the code static String readFixedString(int size, DataInput in)
at the bottom of the page with the code on page 474-475
- Page 472
- In the method "readData", replace DataIO.readFixedString(name,
NAME_SIZE, in); with name = DataIO.readFixedString(NAME_SIZE, in);
- Page 478
- Replace the method "readData" with the one on page 479
- Page 478
- Replace "take care of their data fields." with "take care of
its data fields."
- Page 484
- The code segment at the top, replace the comment // save parent class
with // read(restore) parent class
- Page 488
- At the bottom of the page, replace salary = readDouble(",salary=");
with salary = ps.readDouble(",salary=");
- Page 493
- In the method writeString, replace print((char)ch); with print(ch);
- Page 493
- In the method writeString, remove StringBuffer b = new
StringBuffer(s.length() + x.length() + 2);
- Page 503
- The headers for chapter 12, "Multithreading", are all numbered as
chapter 10. They should be 12
- Page 504
- On the CD-ROM, the method bounce() (in ch12\Bounce directory) sleeps for 5
milliseconds, not 10
- Page 506
- Remove "Before we can get the ball to bounce correctly, we need to
make one more change inside the ball's run method. The original bounce
code kept checking the system time, and only moved the ball after 5 milliseconds
had elapsed."
- Page 511
- Replace "Figure 10-4 shows the states that ..." with "Figure
12-5 shows the states that ..."
- Page 522
- Replace class ImageLoader extends Thread with class
ImageLoader extends ThreadGroup
- Page 527
- In the method run(), replace if(to >= from) to++; with if(to
== from) to = (to + 1) % Bank.NACCOUNTS;
- Page 537
- In class "TimerTest", cross out the line Canvas canvas;
- Page 540
- The code segment in the middle, replace "|" with "}"
- Page 543
- In the method stop(), replace runner.isActive() with runner.isAlive()
- Page 559
- Replace s.start(); with t.start();
- Page 561
- In the class "ThreadedEchoHandler", remove Socket incoming;
and int counter; In the end of the class, add
private Socket incoming;
private int counter;
- Page 561
- In the class "ThreadedEchoHandler", add public in front
of ThreadedEchoHandler(Socket i, int c)
- Page 561
- Add "public" in front of "class ThreadedEchoServer" and
move this class to the beginning of the code
- Page 565
- In the method init(), add line setLayout(new BorderLayout()); at
the beginning
- Page 565
- In the method init(), replace add("South", p); with
add("North", p);
- Page 565
- In the method action, remove the first "else if" clause
- Page 566
- In the method paint, replace int x = 0; with int x = 80;
- Page 567
- In the last paragraph, replace "When the user clicks the Send button,"
with "When the user clicks the Mail button,"
- Page 568
- Replace "it wil not use port 8189." with "it will not use
port 8189."
- page 575
- In method action, remove the first "else if" clause
- Page 577
- Cross out the line private int m = 1;
- Page 580
- The second line from the end, replace "Then the applet shows a list of
cities in the list box on the left." with "Then the applet shows a
list of cities in the list box on the right."
- Page 582
- Replace String query = "/Weather_Text/U.S._City_Forecasts" +
state; with String query = "/Weather_Text/U.S._City_Forecasts"
+ "/" + state;
- Page 582
- Replace int i = line.indexOf('0', 1); with int i =
line.indexOf("0/", 1);
- Page 583
- Replace String query = "/Weather_Text/U.S._City_Forecasts" +
state; with String query = "/Weather_Text/U.S._City_Forecasts"
+ "/" + state;
- Page 585
- In the last line, replace "between the corporate network to the
Internet," with "between the corporate network and the Internet,"
- Page 586
- In the first paragraph, it's William R. Cheswick, not William K. Cheswick
- Page 588
- In class ProxySvr, remove int j = 0; and j++;
- Page 588
- In class ProxySvr, add "public" in front of the "class
ProxySvr"
- Page 589
- In main method, replace if(pos < 0) throw e; with if(pos2
< 0) throw e;
- Page 592
- In fifth paragraph, replace "Neither C nor Java" with "Neither
C nor Perl"
- Page 597*
- The Perl script has two errors. The code $service_name == "http"
should read $service_name eq "http", and likewise $service_name
== "gopher" should be $service_name eq "gopher".
Of course, a really well-designed language would not lead programmers astray
with spurious definitions of == for strings... (see page 65)
- Page 613
- The Calculator class is on page 264, not 339
- Page 696
- In the Employee_raiseSalary function, replace ClassEmployee
with ClassEmployee*.
*: fixed in second printing.
We would like to thank Kamal Abdali, Richard Adler, Mattas Almgre, Ram
Bala, Alexander R. Barwick, Jeff Bensman, Michael Berman, Steve Betz, Eric L.
Blair, Dan Buffum, Mark Castillo, Mark Chamness, Steven Chow, Keh-Cheng Chu,
Dave Claussen, Gary Clayburg, Michael William Clayton, Marcus Crafter, Anand
Daga, Neil Daswani, Chris Dennis, Richard Domer. Scott Dunbar, John Dutton,
Carlos Escalante, Bruce Eckel, Bruce Evans, Walt Farrell, Alan C Francis,
James Francis, Neil Francis, Jay Freedman, Michael Fuerst, Art Gittleman, David
Glaude, Roy Goldman, Aryeh Goldsmith, Adolfo Grego, Chuck Han, William
Harris, Erik Hjelmes, Waikwan Hui, Jason Hulance, David C. Hume, Kel Hunt,
Shinichi Iwamoto, Thomas Johannesson, Bob Johnsen, Russell Johnston, Mark
Kinzie, Henrik Kjell, P.J. LaBrocca, Wilmer Lau, Hai N. Le, April Lee, Joon
Suk Lee, Stephen Lee, Jocelyn Legault, Eric Lu, Chinh Mai, Chris Maloof,
Alexandre Martin, Douglas Martin, Anthony McCarthy, Donald E. McCollam,
Helmut Messerer, Ari Meyer, Sandeep Mitra, Mat Myszewski, Balasubramanian
Narasimhan, Eiji Nishihara, Ralf Nolting, Jeff O'Brien, John Olsson, Fred
Pantalone Jr., Jim Patrick, Tony Peterman, Vanh Phom, Craig Prescott, Jim
Preston, David Prokop, Joe Rantala, Brian Rogoff, Behr de Ruiter, Ursula Rost,
Rob Rucker, Fred Ruddock, Daniel Rybowski, Steve Sanders, Matt Sartori, Max
Schaible, Warren Seltzer, Scott Shifflett, Bryan Smith, George K. Staropoli,
David Starr, Jon Steelman, Paul Stoecker, Leonardo Susatyo, Jonas Svensson,
Peter Teitelbaum, Janet Traub, Thomas J. Trop, Brendan Tompkins, Sashank
Varma, Steve Viens, Ulrich Vollert, Jon W, Don Weiss, Larry Weiss, John N.
Welch, Lau Wilmer, Alice Wong, Hsueh-ching Yen, Rehan Zaidi, Lenny Zeltser,
Zhihong Zou, and a number of anonymous contributors for their bug reports!
Last Modified: 25 Jun 1997
If you have found another bugin the book or in our code that is not
mentioned in this bug list or the
Core Java FAQ, then please send a report. Please do not
bug us with JDK or WinEdit problems, though. Unfortunately, we cannot reply
personally to each report, but we do read all your comments.
Back to the
Core Java page.