Errata

Head First Java

Errata for Head First Java, Second Edition

Submit your own errata for this product.

Have a question? Try the forums at JavaRanch first.

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
Printed
Page xxviii
4th Bullet

Reads "Tha bin directory..." Should this read "The bin directory..."?

Anonymous  Jul 18, 2011  Aug 01, 2014
PDF
Page xii
Chapter 6 sub-chapter listing bullet one

Analying the bug ... isin't it supposed to be 'analyzing'?

Note from the Author or Editor:
Yes, "Analying the bug in the Simple Dot Com Game" should be "Analyzing the bug in the Simple Dot Com Game".

Anonymous  May 23, 2012  Aug 01, 2014
Printed
Page xxviii
4th bullet within "Setting Up Java" block

Reads: "Note: if you have trouble with you installation"
Should Read: "Note: if you have trouble with your installation"

Anonymous  Mar 24, 2013  Aug 01, 2014
Printed
Page xxii
3rd point towards bottom

Do you believe than a technical book can?t be serious if....
should be:
Do you believe that a technical book can?t be serious if...

Anonymous  Jun 24, 2014  Aug 01, 2014
Printed
Page copyright

Add credit to copyright page:
Brain image on spine: Eric Freeman

O'Reilly Media
 
Apr 10, 2018  May 25, 2018
Printed
Page xxvii
10th bullet

For long examples or Ready-bake code, you can download the source files
from headfirstjava.com
->
For long examples or Ready-bake code, you can download the source files
from wickedlysmart.com

########################################

Anonymous    Mar 01, 2011
Printed
Page xxx
2nd paragraph

"...has her SCPJ 1.4 and SCWCD..."
should be:
"...has her SCJP 1.4 and SCWCD..."
^^

Anonymous    Mar 01, 2011
PDF
Page xxvi
2 paragraph

The sentence has the word "coded" twice.

Note from the Author or Editor:
Intro, page xxvi, 2nd paragraph:

"...coded coded..."

should be: "...coded..."

Anonymous  Aug 25, 2010  Mar 01, 2011
Printed
Page 5
2nd paragraph after "A:"

Sentence reads,
So, the original Java was versions 1.02 (the first official release) through 1.1 were just "Java".
Should read,
So, the original Java, versions 1.02 (the first official release) through 1.1, were just "Java".

Anonymous    Mar 01, 2011
Printed
Page 6
hand-written text after "System.out.print("Dog: " + name)

Sentence reads,

print out "Hello Fido"...

Should read,

print out "Dog: Fido"...

Anonymous    Mar 01, 2011
Printed
Page 9
+2

Load the Hello class
->
Load the MyFirstApp class

########################################

Anonymous    Mar 01, 2011
Printed
Page 10
Bullet 2 "do something again and again"

x = x -1
should be
x = x - 1

Anonymous    Mar 01, 2011
Printed
Page 23
middle of page in class Test code

Wrong way double-quotes in
System.out.print(x + "" + y + " ");

Note from the Author or Editor:
In the white box with code, change the quotation marks in the "System.out.print" statement to be straight quotes.

Anonymous    Mar 01, 2011
Printed
Page 24
at botton of page in pool puzzle

The Pool Puzzle snippets
System.out.print("a ");
System.out.print("n ");

should be:
System.out.print("a");
System.out.print("n");
(i.e., remove spaces)

and

System,out,print("an");
should be:
System.out.print("an");

Anonymous    Mar 01, 2011
Printed
Page 47
Pool Puzzle

For pool puzzle on page 44 of Chapter 2, the correct answer on page 47 is NOT the only correct answer. The following permissible code is also correct:

//File: EchoTestDrive

public class EchoTestDrive {
public static void main(String[] args) {
Echo e1 = new Echo();
Echo e2 = new Echo(); //"Echo e2 = e1;" for Bonus

int x = 0;

while ( x < 4 ) {
e1.hello();
e1.count = e1.count + 1;

if (x > 0) {
e2.count = e2.count + 1;
}//This is the end of the 1st conditional

if (x > 1) {
e2.count = e2.count + e1.count;
}//This is the end of the 2nd conditional

x = x+1;
}//This is the end of the 1st while
System.out.println(e2.count);
}//This is the end of the main method
}//This is the end of the class

Note from the Author or Editor:
Add to the end of the "Your job..." paragraph:

Note: Some of the exercises and puzzles in this book might have more than one correct answer. If you find another correct answer, give yourself bonus points!

Anonymous  Sep 20, 2010  Mar 01, 2011
Printed
Page 53
Just right below the 3 bullet rules

Just right below the last bullet of the rules.

"are keywords (and other things) that...."
It should be:
"Reserved words are keywords..."

Anonymous    Mar 01, 2011
Printed
Page 63
Compiler problem B

The problem in the exercise is to find the code which will give compilation errors by
the compiler. However the problem B is fine for the compilation. The error mentioned
in the exercise solution, i.e the ArrayIndexOutOfBoundsException is a runtime
exception, which will never be caught by the compiler.

Note from the Author or Editor:
Change the "Be the Compiler" instructions:

Second sentence should now end: "...will compile and run without exception."

In the last sentence, remove the word "compile".

Anonymous    Mar 01, 2011
Printed
Page 66
left column under "Tip"

on page 55 and 56
->
on page 55 and 57

########################################

Anonymous    Feb 01, 2007
Printed
Page 66
Tip

In the 'Tip', the sentence that starts "Unless you're way smarter than us... it
mentions diagrams "like the ones on page 55 and 56 of this chapter".

remove "and 56"; it doesn't have any diagrams on it.

[and a minor note that I'm sure will be chuckled at.... the first sentence should be
"Unless you're way smarter than we are", not "us".

Note from the Author or Editor:
The "tip" should refer to pages 57-60.

Anonymous    Mar 01, 2011
Printed
Page 68
Solution to "Be The Compiler" exercise B

Should outdent the two boldface lines to match the prior line.

Anonymous    Mar 01, 2011
Printed
Page 69
Output on the Code

In the last line of output on the code, it currently says:

y = 4, t5 area = 343

Since 'area' is of type double, the output should be:

y = 4, t5 area = 343.0

Note from the Author or Editor:
In the black output window change: "... area = 343"

to be: "... area = 343.0"

David Marquis  Nov 05, 2010  Mar 01, 2011
Printed
Page 84
Last paragraph, bottom right of the page, next to the output window

The paragraph "(Remeber, null just means [...]" misses the closing parenthesis.

Anonymous  Aug 11, 2008  Mar 01, 2011
Printed
Page 92
4th paragraph

Maybe not a mistake - a few phrases end with two dots ("it should.." and "your access modi.."), maybe there should be three.

Anonymous  Aug 11, 2008  Mar 01, 2011
PDF
Page 98
Step 1, 2nd paragraph

No closing parenthesis before in last sentence:

"(for example:
1,2,3..."

Anonymous  Nov 23, 2011  Aug 01, 2014
Printed
Page 99
"real code" paragraph

The "To Do" note obscures part of the text after "real code".

Anonymous    Mar 01, 2011
Printed
Page 106
output box in lower right corner

The output of running "java SimpleDotComTestDrive" should read:

hit
passed

instead of just "hit"

Note from the Author or Editor:
Output box in lower right, add the word "passed" underneath the existing word "hit"

Anonymous    Mar 01, 2011
Printed
Page 118
left column

Code for the exercise is missing

Note from the Author or Editor:
Code needs to be added back in:

class Output {

public static void main(String [] args) {
Output o = new Output();
o.go();
}

void go() {
int y = 7;
for(int x = 1; x < 8; x++) {
y++;
if (x > 4) {
System.out.print(++y + " ");
}
if (y > 14) {
System.out.println(" x = " + x);
break;
}
}
}
}

Anonymous  Apr 10, 2011  Jun 10, 2011
Printed
Page 119
2 and 6 code magnets

There is no code in the 2nd magnet, or the 6th magnet. They are blank.

Note from the Author or Editor:

Code needs to be added back in:

for(int x = 0; x < 4; x++) {

Anonymous  May 15, 2011  Jun 10, 2011
Printed
Page 123
Mixed messages puzzle solution

All the candidate blocks of code are blank.

Note from the Author or Editor:

Add Candidates:

x = x + 3;

x = x + 6;

x = x + 2;

x++;

x--;

x = x + 0;

Anonymous  May 15, 2011  Jun 10, 2011
PDF
Page 135
Last ArrayList paragraph, 6th sentence

primtive should be primitive:

"...you can put a primtive in an ArrayList..."

Anonymous  Nov 24, 2011  Aug 01, 2014
Printed
Page 135
Last ArrayList paragraph

The following line should end with a question mark:

But is it worth the miniscule performance gain to give up all this power.

Anonymous    Mar 01, 2011
Printed
Page 139
2nd comment

In the 2nd comment where says: "Change the String array to an ArrayList that holds
Strings" should say: "Change the int array to an ArrayList that holds Strings"
(You are changing from a int[] to a ArrayList<String>.)

Anonymous    Mar 01, 2011
Printed
Page 146
Annotations at bottom of page

In the K&B solution on page 148 for the "Sharpen your pencil" exercise on page 146,
there is an extra annotation that isn't one of the possible annotations listed at the
bottom of page 146. The "extra annotation" shown on page 148 is, "Make an ArrayList
of DotCom objects (in other words, a list that will hold ONLY DotCom obects, just as
DotCom[] would mean an array of DotCom objects).

Anonymous    Mar 01, 2011
Printed
Page 149
4th line of checkUserGuess method

variable userGuess is incorrectly printed with a lower case g (i.e. userguess)
So,

result = dotComsList.get(x).checkYourself(userguess);

should be

result = dotComsList.get(x).checkYourself(userGuess);

Note from the Author or Editor:
5th line of code:
...userguess);

should be:

...userGuess);

Anonymous  May 15, 2011  Jun 10, 2011
Printed
Page 149
9th line of checkUserGuess method

Line reads: dotComsList.remove(dotComToTest);

dotComToTest is not declared anywhere.

I imagine this is an error introduced from the fix of a previous errara.

Line should read: dotComsList.remove(x);

Note from the Author or Editor:
9th line of code that reads:
dotComsList.remove(dotComToTest);

should be:
dotComsList.remove(x);

Anonymous  May 15, 2011  Jun 10, 2011
Printed
Page 149
checkUserGuess method

The method includes the following for loop

for (DotCom dotComToTest : dotComsList) {
result = dotComToTest.checkYourself(userGuess);

if (result.equals("hit")) {
break;
}

if (result.equals("kill")) {
dotComsList.remove(dotComToTest);
}
}

When the program is run under JRE 1.5.0_04, the loop throws a
ConcurrentModificationException after the "dotComsList.remove(dotComToTest);"
statement is executed.

According to what I've been able to find, when using an ArrayList iterator (as the
for-each loop does), it is only legal to modify the ArrayList by using the iterator's
own remove or add methods

(From the JavaDoc for ConcurrentModificationException: "if a thread modifies a
collection directly while it is iterating over the collection with a fail-fast
iterator, the iterator will throw this exception.")

In order to avoid the exception the example code should use a standard for loop.

Note from the Author or Editor:
The 4th line of code that begins: for(DotCom dotComToTest...

should be: for(int x = 0; x < dotComsList.size(); x++) {

The 5th line of code that begins: result = dotComToTest...

should be: result = dotComsList.get(x).checkYourself(userguess);

Anonymous    Mar 01, 2011
Printed
Page 150
Code line: "public void setName..."

This line of code should be outdented to match the curly braces above and below.

Anonymous    Mar 01, 2011
Printed
Page 152
Third line of the placeDotCom method, slightly below the middle of the page.

The line reads:

String [] alphacoords = new String [comSize]; // holds 'f6' type coords

The local string array "alphacoords" appears nowhere else in the placeDotCom method.
I suspect the comment regarding 'f6' coords belongs with the preceding line:

ArrayList<String> alphaCells = new ArrayList<String>();

Note from the Author or Editor:
Change the line of code that begins: String[] aplhacoords = ...

In this line of code, remove everything up to the // and make sure the // ... stays aligned with the comments below it.

Anonymous    Jun 10, 2011
Printed
Page 152
1st paragraph; 4th sentence (of the 2nd edition)

"We tried to keep it fairly small to you wouldn't have to type so much..."
should be:
"We tried to keep it fairly small so you wouldn't have to type so much..."

Anonymous    Mar 01, 2011
Printed
Page 154, 155, 157
References to "chapter 16"

All references to chapter 16 on these pages should be references to chapter 17.

Anonymous    Mar 01, 2011
Printed
Page 180
Note at end of page

Reference to chapter 16 should be a reference to chapter 17.

Anonymous    Mar 01, 2011
Printed
Page 187
1st hand-written paragraph

"The Animal parameter can take ANY Animal type as the argument."
Should be changed to:
"The 'a' parameter can take ANY Animal type as the argument."

Anonymous    Mar 01, 2011
Printed
Page 190
2nd-to-last box, line 2

public boolean turnOn()
->
public boolean turnOff()

########################################

Anonymous    Mar 01, 2011
Printed
Page 195
Mixed messages answer

Misaligned line objects make it unclear just what is the correct answer for this exercise.

Note from the Author or Editor:
The 1st set of 3 on the left should point to the 2nd answer on the right.
The 2nd set of 3 on the left should point to the 4th answer on the right.
The 3rd set should point to the last answer.
The 4th set - add the big curly brace and point it also to the 4th answer.

Anonymous    Jun 10, 2011
Printed
Page 200
The bottom of the right column (the code example)

The highlight for the word abstract is below the code sample in the white space.

Note from the Author or Editor:
At the bottom of the 2nd column the grey highlighting box should be moved up the page so that the word "abstract" is within it.

Anonymous  May 15, 2011  Jun 10, 2011
Printed
Page 208
box, under "boolean remove"

Removes the object at the index parameter. Returns 'true' if the element
was in the last
->
Removes one instance of the object specified in the parameter. Returns
'true' if the element was in the list.

########################################

Anonymous    Mar 01, 2011
Printed
Page 209
References to chapter 17 and appendix B

References to "hashtables in chapter 17" should be changed to chapter 16.
References to appendix B should be removed.

Anonymous    Mar 01, 2011
Printed
Page 212
Inside command window depiction 2/3 of way down the page

Dog sameDog = takeObjects(aDog);
should be:
Dog sameDog = getObject(aDog);

Note from the Author or Editor:
In the output box: "... takeObjects(aDog);"

should be: "... getObject(aDog);"

Anonymous    Mar 01, 2011
Printed
Page 229
2nd paragraph of 'A'nswer on right side of page

"... the compiler knows that its (should be 'it's') safe to cast anything that comes out of ArrayList do (should be 'to')
a dog reference."

Note from the Author or Editor:
in the middle of the 2nd answer paragraph the line: "ArrayList do a Dog..."

should be: "ArrayList to a Dog..."

Anonymous    Mar 01, 2011
Printed
Page 231
Near the bottom of the page

Very minor printing error?
For #4, there is a break in the arrow between the "Baz" and the "Bar"
classes. This line should be solid.

Note from the Author or Editor:
Diagram #4, the arrow between Baz and Bar should be solid.

Anonymous    Mar 01, 2011
Printed
Page 245
3rd paragraph

"clunkly" should read "clunky"

Anonymous    Mar 01, 2011
Printed
Page 247
+1

The class below is legal because all four constructors...
->
The class below is legal because all five constructors...

########################################

Anonymous    Mar 01, 2011
Printed
Page 247
gray box on top right

Four different constructors means four different ways to make a new mushroom.
->
Five different constructors means five different ways to make a new mushroom.

########################################

Anonymous    Mar 01, 2011
Printed
Page 248
Bottom right

Example compiler output window overlaps the last line of text in the answer section.

Anonymous  May 16, 2011  Jun 10, 2011
Printed
Page 249
Answer to first "dumb question"

The answer to the first question is missing "protected" which is a perfectly valid
access modifier for a constructor. (this should also reference appendix B).

Note from the Author or Editor:
First "dumb questions" answer should read: "No, constructors can be public, protected, private,..."

Anonymous    Mar 01, 2011
Printed
Page 254
Second paragraph

"Look at the Stack series on page 248 again."
The page number should be 252, because, thats where the Hippo stack is.

Anonymous    Mar 01, 2011
Printed
Page 254
* Note at the bottom

The note (on page 254) reads: "There's an exception to this rule, you'll learn it on page 252". The errata is obviously the page number 252. Corrige: 256

Note from the Author or Editor:
The note at the bottom of the page should refer to page 256

chevalasco  Dec 31, 2009  Mar 01, 2011
Printed
Page 256
example

Color.Red is invalid; should be either Color.red or Color.RED.
In any case, introducing an previously unmentioned variable type here, in the middle of a difficult concept, is just distracting. I had to look it up as I didn't know about color variable dot syntax.

Note from the Author or Editor:
Three changes to the code:

Before the line: "class Mini..."
add: import java.awt.Color;

Then, the two instances of "Red" should be "RED"

Anonymous  Jan 29, 2010  Mar 01, 2011
Printed
Page 260
1st paragraph

"The rules are the same for primtives and references."

"primtives" should read "primitives"

Anonymous    Mar 01, 2011
Printed
Page 266
Execise method "public static void doStuff2"

The line "GC localGC" is incomplete. This will certainly have a compilation error.

Note from the Author or Editor:
Near the bottom, the line that reads: GC localGC =

Should be:

GC localGC = copyGC;

Anonymous    Jun 10, 2011
Printed
Page 266
doStuff2 method

The statement
GC localGC
must end in a semicolon.

Anonymous    Mar 01, 2011
Printed
Page 275
1st column, regular (non-static) method

Missing closing curly brace, "}", at the end of public class Song.

Anonymous    Mar 01, 2011
Printed
Page 282
10 th paragraph

Under static initializer (upper right side of the page)

class Foo{
final static int x;
static {
x = 42;

}
}

the "x" in "final static int x" should be in CAPS (X):

class Foo{
final static int X;
static {
X = 42;
}
}

Note from the Author or Editor:
In the grey box in the upper right corner of the page, both occurrences of the variable "x" should be capitalized to "X".

Derril Filemon  Jan 12, 2011  Mar 01, 2011
Printed
Page 290
bottom example "Boolean expressions"

In the diagram, "boolean object" should be spelled "Boolean object".

Ken A Collins  Jul 02, 2011  Aug 01, 2014
Printed
Page 292
4th line of code under "Converting a string..."

boolean b = new Boolean("true") .booleanValue();
->
boolean b = Boolean.parseBoolean("True");

########################################

Anonymous    Mar 01, 2011
Printed
Page 292
2nd annotation on page

You'd think there would be a Boolean.parseBoolean() wouldn't you? But there
isn't. Fortunately there's a Boolean constructor that takes (and parses) a
String, and then you just get the primitive value by unwrapping it

->

The (new to 1.5) parseBoolean() method ignores the cases of the characters
in the String argument.

########################################

Anonymous    Mar 01, 2011
Printed
Page 304
Middle, next to the girl

...but you can get a ...
instead of
...but you can can get a ...

Anonymous  Sep 06, 2011  Aug 01, 2014
Printed
Page 306
1st paragraph

should read "rest of this API" currently is "rest of the this API"

Anonymous  May 03, 2011  Jun 10, 2011
317
Chapter 11- We'll start with the basica 4th paragraph

Jimmy Hendrix should be changed to Jimi Hendrix

Joe Colantonio  Jan 22, 2013  Aug 01, 2014
Printed
Page 323
Bottom of page (next to last line)

Close parenthesis missing for the "catch block".

this code fragment should read:

public void crossFingers() {
try {
anObject.takeRisk();
} catch (BadException ex) {
System.out.println("Aaargh!");
}
}

Note the addition of the next-to-last close parenthesis...

Note from the Author or Editor:
Code at the bottom of the page, add a closing, indented "}" so it looks like this:

}
}

Anonymous    Mar 01, 2011
Printed
Page 326
Block of text above the console screen at the right bottom of the page

2nd edition.

The underline looks out of place.

Marcos Maximo  Jan 18, 2010  Mar 01, 2011
Printed
Page 336
Block of text below the image that shows only "main()" on the stack

Something is strange here. In this text, it says that after foo() pops off the stack, there is nobody left to handle the exception, but there's still main(). I think that making the change "foo()" -> "main()" would solve the problem (if the reader assumes that "..." in "But foo() doesn't have a try/catch, so..." means that more text describing the process was omitted because the reader already knows what happens), but I would prefer that more text is added to make things clear.

Note from the Author or Editor:
Change the beginning of the description under the "main()" graphic to read:

foo() pops off the stack and the exception is thrown back to main(). But main() doesn't have a try/catch so the exception is thrown back to...

Editor note: From there use the existing text.

Anonymous  Jan 19, 2010  Mar 01, 2011
Printed
Page 340
Below the big bold word "Track" (thing 3)

2nd edition.

Minimal typo here (simple quotes): "For this book (...) so just imagine 'a a' music CD with (...)" -> There are two "a"s.

Marcos Maximo  Jan 19, 2010  Mar 01, 2011
PDF, Mobi
Page 351
left column of page

"is synonomous" should be "is synonymous"

Anonymous  Sep 23, 2013  Aug 01, 2014
354
First line at the second column (Title)

Ir is written this way which appears letters are missing.

Ma i g a GUI is easy:

Note from the Author or Editor:
This problem doesn't show up in the PDF, but does on Safari.

It appears in two places on the page:

"If I see one more
command-line app,
you're fired."

AND

"Making a GUI is easy:"

Abder-Rahman  Jun 12, 2010  Sep 23, 2011
Printed
Page 360
Getting a button's ActionEvent #3

Change:
"...method from the ActionListener interrface"
To:
"...method from the ActionListener interface"

Anonymous    Mar 01, 2011
Printed
Page 365
Code in top half of page

The line

Image image = new ImageIcon("catzilla.jpg").getImage();

won't work for anyone using Netbeans or Eclipse IDEs because it won't find the image file, and cause hours of grief (as it did for me). It would be better to use the syntax

Image image = new ImageIcon(getClass().getResource("catzilla.jpg")).getImage();

since this will work both from the command line and within IDEs.

Note from the Author or Editor:
Amend the annotation that says: "your file name goes here" to be:

your file name goes here. Note: If you're using an IDE and have difficulty, try this line of code instead: Image image = new ImageIcon(getClass().getResource("catzilla.jpg")).getImage();

Anonymous  Feb 06, 2011  Mar 01, 2011
Printed
Page 365
Code at the bottom

(int) (Math.random() * 255)

should be

(int) (Math.random() * 256)

just as on page 367... since Math.random() is always < 1 and the (int) cast always rounds down

Note from the Author or Editor:
Six instances of: (Math.random() * 255)

should all be changed to (Math.random() * 256)

Anonymous  Feb 06, 2011  Mar 01, 2011
Printed
Page 366
Halfway down, left column

Text says

You can NOT say:
a.bark();

This is true but meaningless, just as you can NOT get up in the morning, but you choose to do so. It should be

You CANNOT say:
a.bark();

Note from the Author or Editor:
Change: You can NOT say:

to: You CANNOT say:

Anonymous  Feb 06, 2011  Mar 01, 2011
Printed
Page 367
code at bottom

int red = (int) (Math.random() * 255);
int green = (int) (Math.random() * 255);
int blue = (int) (Math.random() * 255);
Color startColor = new Color(red, green, blue);

red = (int) (Math.random() * 255);
green = (int) (Math.random() * 255);
blue = (int) (Math.random() * 255);
Color endColor = new Color(red, green, blue);

->

int red = (int) (Math.random() * 256);
int green = (int) (Math.random() * 256);
int blue = (int) (Math.random() * 256);
Color startColor = new Color(red, green, blue);

red = (int) (Math.random() * 256);
green = (int) (Math.random() * 256);
blue = (int) (Math.random() * 256);
Color endColor = new Color(red, green, blue);

########################################

Anonymous    Mar 01, 2011
Printed
Page 368
6th paragraph on the right side

"and draw the imagine using" should be "and draw the image using"

Anonymous  Sep 28, 2011  Aug 01, 2014
Printed
Page 368
5th paragraph in righthand column

graphics.setColor(Color.blue);
should be:
g.setColor(Color.blue);

Note from the Author or Editor:
Fifth bullet in right column the line: graphics.setColor...

should be: g.setColor...

Anonymous    Mar 01, 2011
Printed
Page 370
Sharpen your pencil box

Given the pictures on page 351
->
Given the pictures on page 369

########################################

Anonymous    Mar 01, 2011
Printed
Page 370
in the note on the left; 2nd paragraph

regsion
should be:
region

Anonymous    Mar 01, 2011
Printed
Page 370
Sharpen your pencil

Refers to pictures on p351, should be p369.

Note from the Author or Editor:
In the "sharpen" the page number should be: 369

Anonymous    Mar 01, 2011
Printed
Page 371
last line of code

// See page 347 for the code
->
// See page 367 for the code

########################################

Anonymous    Mar 01, 2011
Printed
Page 371
The bottom source code

The comment in the paintComponent method of the MyDrawPanel refered to the wrong
page.

//See page 347 for the code
should read:
//See page 367 for the code

Note from the Author or Editor:
The last code comment on the page should read:

// See page 367 for the code

Anonymous    Mar 01, 2011
Printed
Page 387
Right hand side bottom section

Third bullet point is incorrectly labeled as bullet point 4.

Anonymous    Mar 01, 2011
Printed
Page 391
MyDrawPanel line 18

g.fillRect is called with height and width reversed - should be:

g.fillRect(x, y, width, ht);

Note from the Author or Editor:
Code near the bottom of the page, the line: g.fillRect...

should be: g.fillRect(x, y, width, ht);

Anonymous    Mar 01, 2011
Printed
Page 392
Sharpen your pencil

"It builds directoy..."
should read:
"It builds directly..."

Anonymous    Mar 01, 2011
Printed
Page 393
2nd paragraph

There is an unused cast to Graphics2D, in the paintComponent method.

To be more precise, the following cast

Graphics2D g2 = (Graphics2D)g;

is never used, and can be removed.

Note from the Author or Editor:
Remove the (unused) line of code:

Graphics2D g2 = (Graphics2D) g;

Anonymous  Mar 09, 2010  Jun 10, 2011
Printed
Page 393
& <396> Entire page

Pages 393 and 396 are missing from the first printing. A PDF file of the missing pages
can be found here - http://examples.oreilly.com/9780596009205/HFJava_393_396.pdf

Anonymous    Mar 01, 2011
Printed
Page 396
code

The line
"public void paintComponent (Graphic" should read,
"public void paintComponent (Graphics" - the trailing "s" in "Graphics" is missing.

Anonymous    Mar 01, 2011
Printed
Page 397
"Who am I?" solution, 13th clue answer

"Graphics2d" -> "Graphics2D"

Note from the Author or Editor:
Who am I, antepenultimate answer, change from: "Graphics2d"

to: "Graphics2D"

Anonymous  Jan 21, 2010  Mar 01, 2011
Printed
Page 398
method go(), for loop ending statement

Minimal typo: there isn't a "i++,x++,y++" code snippet in this puzzle, so the correct would be "i++,y++,x++".

Note from the Author or Editor:
WOW!!!! In my copy of the 2nd edition, pages 393 and 396 ARE MISSING, and because of that, pages 394 and 395 ARE BACKWARDS.

Once that's fixed, we can verify the possible typo.

O'Reilly production:
Unfortunately that must have been a printer error as our books in-house have those pages.

Anonymous  Jan 21, 2010  Sep 23, 2011
Printed
Page 409
Woman's thought bubble

The text should read, "I need to know how big the button wants to be..."
The word "be..." is missing.

Anonymous    Mar 01, 2011
Printed
Page 417
Constructor

list = new JList(listEntries);
should be:
JList list = new JList(listEntries);

to remain consistent with the preceding pages

Note from the Author or Editor:
Constructor, 2nd line of code should be:

JList list = new JList(listEntries);

Anonymous    Mar 01, 2011
Printed
Page 420
In main()


The book shows main() as follows:

public static void main (String[] args) {
new BeatBox2().buildGUI();
}

when in fact I had to use:

public static void main(String[] args) {
BeatBox box = new BeatBox();
box.buildGUI();
}

Note from the Author or Editor:
In the main() method: ...BeatBox2()...

should be: ...BeatBox()...

Anonymous  Aug 15, 2010  Mar 01, 2011
Printed
Page 422
third handwritten comment from the bottom

"Let's..."
should read:
"Lets..."

Anonymous    Mar 01, 2011
Printed
Page 422
a little more than 1/3 of the way down

JCheckBox jc = (JCheckBox) checkboxList.get(j + 16*i);
may be changed to:
JCheckBox jc = checkboxList.get(j + 16*i);

The "(JCheckBox)" cast is superfluous.

Note from the Author or Editor:
Change the line of code, about 1/2 way down the page:

JCheckBox jc = (JCheckBox) checkboxList.get(j + 16*i);

may be changed to:

JCheckBox jc = checkboxList.get(j + 16*i);

Anonymous    Mar 01, 2011
Printed
Page 423
Text that explains code inside if in method makeTracks

"NOT OFF" -> "NOTE OFF"

Anonymous  Jan 22, 2010  Mar 01, 2011
Printed
Page 435
Brain Barbell text para 3

replace "Carburator" with "Carburetor"

Note from the Author or Editor:
In the Brain Barbell the word: Carburator

should be: Carburetor

HandyAllan  Dec 01, 2010  Mar 01, 2011
Printed
Page 444
Bottom of page (command window depiction)

The contents of the command window should be changed from:

% java GameSaver
Elf
Troll
Magician

to:

% java GameSaverTest
One's type: Elf
Two's type: Troll
Three's type: Magician

Note from the Author or Editor:
The contents of the command window should be changed from:

% java GameSaver

Elf
Troll
Magician

to:

% java GameSaverTest

One's type: Elf
Two's type: Troll
Three's type: Magician

Anonymous    Mar 01, 2011
Printed
Page 447
in the box in the upper-right corner

after the comma between "bow" and "sword" the is a space, while there are no space after any of the other comma's.

Anonymous    Mar 01, 2011
Printed
Page 452
Rightmost comment

In the sentence, "A File object is like a street address... it represents the name
and location of a particular file..." the word "represents" appears to be crossed out
when it should be underlined.

Anonymous    Mar 01, 2011
Printed
Page 459
Make it Stick

The "Make it Stick" box is overlapping the "Bullet Points" icon.

Anonymous    Mar 01, 2011
PDF
Page 460
2nd last sentence, left column

"affect" should be "effect":

"...has no affect on..."

Anonymous  Dec 01, 2011  Aug 01, 2014
Printed
Page 461
In the code boxes

The serialVersionUID generated by serialver differs from the one pasted into the class, respectively (with underscores highlighting differences):
-_5_849794470_6_54667_2_10L
-_6_849794470_7_54667_7_10L

Note from the Author or Editor:
Add a hand-drawn arrow and annotation to the right of the small screen shot in the right column that says:

<--- Based on the version of Java you're using, this value might be different.

Anonymous  Jan 12, 2011  Mar 01, 2011
Printed
Page 463
Last two lines of code

The last two lines of code should be outdented to line up with the first two lines.

Anonymous    Mar 01, 2011
Printed
Page 467
2nd sentence

Change the question mark at the end of this sentence to a period: "Reconstruct the
code snippets to make a working Java program that produces the output listed below?"

Anonymous    Mar 01, 2011
Printed
Page 471
Middle of line 5

"And the BufferedReader could care less"

Should probably be "couldn't care less".

Unless BufferedReader actually cares atleast a little bit about where the data comes from.

Anonymous  Jul 01, 2011  Aug 01, 2014
Printed
Page 471
Photo

The phone has little bubbles coming out if it like it's going to say something, but
there's no thought bubble.

Note from the Author or Editor:
Remove the bubbles coming from the phone.

Anonymous    Mar 01, 2011
Printed
Page 481
Largest arrow paragraph

Change the sentence, "In other words, by the time you call a BufferedWriter method,
the writer doesn't know or care where the characters came from."

To: "In other words, by the time you call a BufferedReader method, the reader doesn't
know or care where the characters came from."

Anonymous    Mar 01, 2011
Printed
Page 485
7th bullet point, 3rd line

sock.getInputStream();
->
sock.getInputStream();
sock.getOutputStream();

########################################

Anonymous    Mar 01, 2011
Printed
Page 487
last annotation

Remember, the writer is chained to the input stream...
->
Remember, the writer is chained to the output stream...

########################################

Anonymous    Mar 01, 2011
Printed
Page 488
last para

typo: "How do you do you do"

Note from the Author or Editor:
Last paragraph change:

"How do you do you do two things..."

to: "How do you do two things..."

Anonymous  Jan 15, 2011  Mar 01, 2011
PDF
Page 489
3rd paragraph, left column

Period missing from last sentence:

"A new, separate stack"

Anonymous  Dec 03, 2011  Aug 01, 2014
Printed
Page 507
in function "public void run ()"

Typo on makeWithdrawl(10)
should be: makeWithdrawal(10)

Anonymous    Mar 01, 2011
Printed
Page 510
5th paragraph

"So if you don't lock the back account"
should read
"So if you don't lock the bank account"

Anonymous    Mar 01, 2011
Printed, PDF
Page 510
footnote

"parcticle" should be "particle"

Note from the Author or Editor:
In the hand-written note at the bottom of the page: parcticle

should be: particle

xehpuk  Oct 09, 2010  Mar 01, 2011
Printed
Page 512
Whole page

I'm confirming that "balance++" is not atomic, and here's why:
the corresponding assembly langugage (which is what is being run) is not.

Pegagogically, though, it may be helpful to represent this as 2 statements. But if you do, I suggest a note explaining that the ++ operator is not atomic.

Note from the Author or Editor:
Several changes to this page:

1 - Add a handwritten annotation, pointing to the step line of code: balance = i + 1;

The annotation should read: probably not an atomic process

2 - Replace the two paragraphs after the above line of code with the following:

Note: Even if we used the more common syntax: balance++; there is no guarantee that the compiled bytecode will be an "atomic process". In fact, it probably won't.

Anonymous  Oct 02, 2008  Jun 10, 2011
Printed
Page 515
Thread B, 3rd paragraph

[now thread B is sent into a 'object lock not available lounge]
should read:
[now thread B is sent into an 'object lock not available' lounge]

Anonymous    Mar 01, 2011
Printed
Page 518
method go()

TextArea incoming does not appear to fit the frame initially without resizing of the window.

I think you need (something like) either:
incoming = new JTextArea(15, 30);
or:
frame.setSize(800, 500);

Note from the Author or Editor:
Near the bottom, the code: frame.setSize(400,500);

should be:

frame.setSize(800,500);

HandyAllan  Dec 18, 2010  Jun 10, 2011
Printed
Page 525
The "return counter" box - top right of page

The semicolon (";") which should be in the "return counter" box is actually in the "counter += add;" box.

Anonymous    Mar 01, 2011
Printed
Page 533
HashMap

"Let's..."
should be:
"Lets..."

Anonymous    Mar 01, 2011
Printed
Page 533
LinkedList bullet point

Paragraph states that LinkedList is designed to give better performance when inserting/deleting from the middle of a collection.

I don't know what was the design intention (the documentation doesn't state what it was), but performance data shows that LinkedList performance is significantly WORSE for inserting/deleting in the middle of a collection, e.g.:

http://onjava.com/pub/a/onjava/2001/05/30/optimization.html?page=3

LinkedLists do give better performance for inserting at the BEGINNING (not middle), and apparently for operations involving iteration over list elements.

Note from the Author or Editor:
The paragraph describing LinkedList should be changed to read:

Makes it easy to create structures like stacks or queues.

Anonymous  Feb 26, 2011  Mar 01, 2011
Printed
Page 537, 546
In the getSongs() method, the first line in the try block

File file = new File("SongList.txt");
should be as follows:
File file = new File("SongListMore.txt");

Anonymous    Mar 01, 2011
Printed
Page 542
1st paragraph

Two errors:
1) "They" should be "The" in the second sentence.
2) "3)" should be "2)" on the second bullet.

Anonymous    Mar 01, 2011
Printed
Page 554
main method

new SortMountain
should be:
new SortMountains
The answer page (p 577) for this exercise has the same error.

Anonymous    Mar 01, 2011
Printed
Page 566
1st paragraph

1st sentence:
... "how the object's should be sorted."

should be
... "how the objects should be sorted."

Anonymous  Oct 01, 2008  Mar 01, 2011
Printed
Page 579
Fourth box down

ArrayList<Dog> dogs = new ArrayList<Dog>(); should compile.

Note from the Author or Editor:
The 4th answer should be checked (as correct)

Anonymous  Aug 31, 2010  Mar 01, 2011
Printed
Page 584
Last line on page - Running your code

%java Mini
should read:
%java MyApp

Note from the Author or Editor:
The last command on the page:

%java Mini

should read:

%java MyApp

Anonymous    Mar 01, 2011
Printed
Page 585
2nd bullet

The second bullet contains a superfluous "a". The sentence reads, "Make a text file
named manifest.txt that has a one line:". The "a" before "one" is unnecessary.

Anonymous    Mar 01, 2011
Printed
Page 585
Last bullet 3

%cd MiniProject/classes
should read:
%cd MyProject/classes

Note from the Author or Editor:
Command in step 3 should change:

%cd MiniProject/classes

should read:

%cd MyProject/classes

Anonymous    Mar 01, 2011
Printed
Page 586
Answer to first Question

The last sentence of the first Answer should end in a period
instead of a question mark: "... even then the JVM looks only
in the directories that match the package statement."

Anonymous    Mar 01, 2011
Printed
Page 591
+3 (last sentence obscured by graphic)

Compiling with -d tells the compiler to not just <i>put</i> your classes into
correct directory tree, but to the directories if they don't...
->
Compiling with -d tells the compiler to not just <i>put</i> your classes into
the correct directory tree, but to <i>build</i> the directories if they don't exist.

########################################

Anonymous    Feb 01, 2007
Printed
Page 591
Paragraph 3

The end of the paragraph is obscured by the graphic.

Anonymous    Mar 01, 2011
Printed
Page 593
2nd bullet

"... you'll see the META-INF directory and the com directory directory in your current directory"
Remove extra directory after "the com"

Anonymous    Mar 01, 2011
Printed
Page 596
First Paragraph

Sentence "The clients would always be up-to-date, and you'd never have to worry about delivering new" is unfinished.

Note from the Author or Editor:
Delete the last sentence in the thought bubble.

B Hillebrecht  Jun 17, 2009  Mar 01, 2011
Printed
Page 599
First sentence

Sentence should read, "To make a Java Web Start app, you need to create a .jnlp (Java
Network Launch Protocol) file ..."

Anonymous    Mar 01, 2011
Printed
Page 612
2nd sentence

... "as though its calling a method"...

should be

... "as though it's calling a method"...

Anonymous  Oct 09, 2008  Mar 01, 2011
Printed
Page 618
First Paragraph

Printed: "It uses a naming convention that is the name of your remote implementation, with either _Stub or _Skeleton added to the end."

Correction: Printed: "It uses a naming convention that is the name of your remote implementation, with either _Stub or _Skel added to the end."

B Hillebrecht  Jun 17, 2009  Aug 01, 2014
Printed
Page 623
last bullet

"reigstry" should be "registry"

Note from the Author or Editor:
Last bullet "reigstry" should be "registry"

Ken A Collins  Jun 01, 2011  Jun 10, 2011
Printed
Page 626
Header

There is a typo in header. There is:

"Step for making and running a servlet"

Should be:

"Steps for making and running a servlet"

siwinski.info  Jul 02, 2014  Aug 01, 2014
Printed
Page 627
middle

"reuslt" should be "result"

Note from the Author or Editor:
In the 4th code annotation "reuslt" s/b "result"

Ken A Collins  Jun 01, 2011  Jun 10, 2011
Printed
Page 669
2nd line,

"mor" should be "more"

Anonymous    Mar 01, 2011
Printed
Page 674
Last sentence in 1st paragraph

To be "state of the art," the Traverser's code would need to be Java 5, not Java 1.4.

Note from the Author or Editor:
End of para. 1 should read:

... state of the art Java 6 code.

Anonymous    Mar 01, 2011