Errata

Head First Java

Errata for Head First Java, Third Edition

Submit your own errata for this product.

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
Page pages 334 and 364
bottom half (both pages), 2nd code example

On page 334 the original line reads:

Given the following compilable statements (they both do the same thing):
Collections.sort(myArrayList, myCompare);
myArrayList.sort(myCompare);

In the solution (page 364) the second line and the accompanying text in parentheses are omitted:

Given the following compilable statement:
Collections.sort(myArrayList, myCompare);

Q: Which version is correct/should be used?

Note from the Author or Editor:
The solution used a shorthand version, the important point being the answers. However, if it seems this might cause confusion, the same text could be used on both pages:

Given the following compilable statements (they both do the same thing):
Collections.sort(myArrayList, myCompare);
myArrayList.sort(myCompare);

Jørgen Lang  Sep 13, 2022 
Page Chapter 3. Know your variables: Primitives and References
7th and 9th paragraph of chapter 3.

The line entered as "Besides a type, a variable needs a name so that you can use that name in code." in the 7th paragraph of chapter 3 is reentered in the 9th paragraph of chapter 3 as "Besides a type, a variable needs a name so that you can use that name in code.".

Note from the Author or Editor:
Error not present in the printed book, or in the PDF version I'm looking at, however it is present in the O'Reilly learning platform version.

The first instance of "Besides a type, a variable needs a name so that you can use that name in code." should be removed. Only the second one, between the two highlighted callouts, is required.

Logesh Ponnusamy  Oct 04, 2022 
Page Ch 5 - Just the new stuff
Middle of page in graphic

Section: Just the new stuff: #1 mentioned "break" see #4 below and it should be, see #3 below. There is no #4 in the code or in the image.

Erik Weibust  Oct 11, 2022 
Page 25
top right

Text: Sharpen your pencil (from page 14)
Erratum: exercise is actually on page 15
Suggested fix: change "page 14" to "page 15"

Jørgen Lang  Jun 21, 2022 
Page 40
top left

In edition 2 there used to be examples for the classes Player and GameLauncher in the top left corner of page 40. These are missing in Ed 3. Were they left out intentionally?

Note from the Author or Editor:
I don't think these were removed on purpose, we should bring them back.

Jørgen Lang  Jun 27, 2022 
Page 49
sentence before the last

"(like the difference between primited[!] and references)"
I can't find much information about the word "primited" in dictionaries. Is this supposed to mean "primitives"?

Note from the Author or Editor:
Argh!! Yes, this should be "primitives and references"

Fritz Pick  Aug 02, 2022 
Page 52
last paragraph (examples)

`boolean isLearning;` is described as "declare a boolean named isCrazy [sic] (no assignment".

`isLearning = true;` is described as "assign the value true to the previously declared isCrazy [sic]"

Note from the Author or Editor:
Text should read:

declare a boolean named isLearning (no assignment)
assign the value true to the previously declared isLearning

Fritz Pick  Aug 02, 2022 
Page 96
5th para "How to play", 2nd sentence

redundant closing ), either after "a cell" or after "etc.".

Note from the Author or Editor:
Remove the ")." after 'as "A3", "C5", etc.'

Jørgen Lang  Jul 13, 2022 
Page 109
bullet list, left column, last entry

Last bullet point in left column appears to be out of context.
Original: "????A class can have one superclass only."
This is possibly a copy/paste relict.

Suggested action: Remove this bullet point or clarify.

Note from the Author or Editor:
Agree - remove this bullet point.

Jørgen Lang  Jul 25, 2022 
Page 118
output options on the right

The correct output i.e `13 15 i = 6` is missing.

Note from the Author or Editor:
True. The terminal outputs need changing from "x" to "i":

12 14 x = 6 should be 12 14 i = 6
13 15 x = 6 should be 13 15 i = 6

Fritz Pick  Aug 02, 2022 
Page 122
BE the JVM output

the solution suggests the output of the program would be "13 15 x = 6" when in fact it is "13 15 i = 6".

Note from the Author or Editor:
Confirmed, the output should be

13 15 i = 6

Fritz Pick  Aug 02, 2022 
Page 132
List of methods for ArrayList (box at bottom right)

Inconsistent use of <<true>> (without quotes) vs "true" (with quotes):

contains(Object o)
Returns true if this list contains the specified element.

isEmpty()
Returns “true” if the list contains no elements.

Suggested fix: remove quotes from isEmpty() explanation, since return value is a boolean, not a string.

Note from the Author or Editor:
Agree, remove quotes from isEmpty explanation

Jørgen Lang  Jul 18, 2022 
Page 156
bullet points, entry #9

Original: "You declare the type of the array using a type parameter, which is a type name in angle brackets. Example: ArrayList<Button> ……"
Problem: Usage of "type of array" could be misleading.
Possible fix: Change text to: "You declare the type of the ArrayList using a type parameter, which is a type name in angle brackets. Example: ArrayList<Button> ……"

Jørgen Lang  Jul 20, 2022 
Page 261
bottom right, bullet point (4), 2nd sentence

Original text: When go()
resumes where it left
off, “x” and “x” are both
alive and back in scope.
Variable “b” is still alive.

Problem: "'x' and 'x'" should probably read as, "'x' and 'z'"

Note from the Author or Editor:
I can confirm this should be

..."x" and "z" are both alive...

Jørgen Lang  Aug 26, 2022 
Page 297
Hint on right side

Original: "Note: if you already know printf() from c/C++, you can probably ..."
Problem: Tiny typo: "c/C++": c should be uppercase
Solution: Write as "C/C++"

Jørgen Lang  Aug 31, 2022 
Page 312
top paragraph

Text: the songDB ArrayList was declared on the last page.
The text should read: the songs ArrayList was declared on the last page.

Eduardo M. Hernandez  Oct 24, 2022 
Page 335
numbered list, #2

Original: "Using songLists.sort(artistCompare) […]"
Problem: "songList" is singular.
Fix: "Using songList.sort(artistCompare) […]"

Jørgen Lang  Oct 13, 2022 
Page 358
Comments in the code

Original text: Pass a List<Animal> into our testAnimals method
It should read: Pass a List<Animal> into out takeAnimals method

Eduardo M. Hernandez  Oct 25, 2022 
Page 359
Code comment

Original Text: Will this work now that we changed from an array to a List?
It should read: Will this work now that we changed from a List<Animal> to a List<Dog>?

Note from the Author or Editor:
Should be "Will this work now that we have changed from a List<Animal> to a List<Dog>?"

Eduardo M. Hernandez  Oct 25, 2022 
Page 385
Code section in the middle of the page

There are 2 places to fix:
Original text: Stream<String> limit = strings.stream().limit(4).collect(Collectors.toList());
Corrected text: List<String> limit = strings.stream().limit(4).collect(Collectors.toList());

Original text: System.out.println("result = " + result);
Corrected text: System.out.println("limit = " + limit);

Note from the Author or Editor:
I can confirm this is indeed an error, and the suggested corrections should fix the problem.

In addition, the terminal output further down the page also needs to be changed, from
result = [I, am, a, list]

to

limit = [I, am, a, list]

HATEF PALIZGAR  Jul 19, 2022 
Page 418
solution "BE the Compiler" 4th "manuscript" annotation

Original text: "This single-line lambda effectively returns a String
when a consumer method should return nothing."

Q: Can it be assumed that the notion of a "consumer method" is known to all readers? AFAIK this is normal Java lingo. But since this is a book for non-Java-Heads it might make sense to at least give a bit of a definition/hint on first mention.

Note from the Author or Editor:
The code assigns the lambda to a Consumer variable, so that's the context for that annotation. Perhaps it might be clearer to write the annotation as:

"This single-line lambda effectively returns a String when a Consumer method should return nothing."

(capitalise Consumer)

Jørgen Lang  Sep 23, 2022 
Page 428
Paragraph before the code example

Original text: the catch argument is declared as type Exception, and the parameter reference variable is ex.

It should read: the catch argument is declared as type Exception, and the parameter reference variable is e.

Note from the Author or Editor:
Confirmed. Should say "e" in the text.

Eduardo M. Hernandez  Oct 26, 2022 
Page 431
"metacognitive tip"

Box title "metacognitive tip" is set in a different font than on pages 33 and 108.

Note from the Author or Editor:
Confirmed. However, formatting in Head First Java is intentionally not consistent. Correcting to use the same font as 33 and 108 is nice but not mandatory.

Jørgen Lang  Jul 15, 2022 
Printed
Page 449
Point 3

Code says:

MidiEvent noteOn = new MidiEvent(a, 1);

It should include the message we built in point 2:

MidiEvent changeInstrument = new MidiEvent(msg, 1);

Trisha Gee
Trisha Gee
 
Oct 18, 2022 
Page 452
last paragraph, 2nd sentence

Original: "This gets us ready for the final version (Chapter 15)."
Problem: In contrast to the previous edition, final version is in ch 17.
Solution: Change "(Chapter 15)" to "(Chapter 17)"

Note from the Author or Editor:
This is actually on p453. Yes, this should be corrected to "This gets us ready for the final version (Chapter 17)."

Jørgen Lang  Sep 28, 2022 
Page 472
paintComponent method comment

Original text: This is the Big Important Graphics method.

It should say: This is the Big Important paintComponent method.

Note from the Author or Editor:
It's not necessarily incorrect, but it's also not very clear. It's meant to mean this is the important method for drawing graphics. It's from JComponent, it's not super clear whether the important thing is the method and where it's from, or if it's the parameter Graphics which is important. I would reword this to:

"This is the Big Important drawing method."

Or even simply "This is the Big Important method."

Eduardo M. Hernandez  Oct 29, 2022 
Page 479
code example @ page bottom, last line of comment

Original: // See page 365 for the code
Problem: Code is actually on page 473
Solution: Change "page 365" to "page 473"

Jørgen Lang  Sep 30, 2022 
Page 490
top left

Original: page heading reads: "object lifecycle"
Problem: The contents of the page refers to usage of lambdas instead of inner classes
Suggestion: Maybe a heading matching the contents might be a better choice.

Note from the Author or Editor:
Agree that "object lifecycle" is incorrect. I would change to "inner classes as lambdas".

Jørgen Lang  Oct 06, 2022 
Page 532
3rd code annotation

Original: do this for each of the 16 ROWS (i.e., Bass, Congo, etc.)
Problem: Congo is a country
Solution 1: Specify if you mean République du Congo or République démocratique du Congo
Solution 2: Correct to “Conga” (the percussion instrument)

:)

Note from the Author or Editor:
Congo should be "Conga"

Jørgen Lang  Oct 11, 2022 
Page 536
below crossword grid, clue for 8 down

Original: 8. Romulin command
Problem: The extraterrestrial race who use a cloaking device for their "birds of prey" are called "Romulans".
Solution: Ask a Trekkie. Change "i" to "a".

Jørgen Lang  Oct 11, 2022 
Page 548
bold annotation on mid-right of page, 2nd paragraph

Original: "You can’t serialize a Pond object if its Duck instance variable refuses to be serialized (by not implementing Serializable)."

Problem: Not the instance variable but the class whose object (Duck) should implement Serializable. The way it's currently written it sounds like the instance variable itself should implement Serializable.

Possible fix: Clarify that the instance variable actually references a Duck object and that class Duck should implement Serializable.

Note from the Author or Editor:
Fair comment. It's not necessarily an error but text is unclear. It would probably be better as:

"You can’t serialize a Pond object if its Duck instance variable refuses to be serialized (because the Duck class doesn't implement Serializable)."

Jørgen Lang  Oct 17, 2022 
Page 556
numbered list on right side, step #5

Original: (5) Serialization fails!!

Problem: The serialization was successful (in step #2). The *de*serialization fails. The object can't be brought back to life since the class has a different version ID than what the object was "stamped" with.

Suggested fix:
. Change text for step #4 to: "You try to deserialize a Dog object […]"
. Change "Serialization fails!!" to "Deserialization fails!!"

Note from the Author or Editor:
Yes, accurate, although not a major problem in my opinion.

I would not change the text in #4, because the step you're doing is deserializing, regardless of the outcome.

I would change #5 to "Deserialization fails!!"

Jørgen Lang  Oct 19, 2022 
Page 592
1st paragraph

Original Text: FTP? 20.

Should be: FTP? 21.

Note from the Author or Editor:
Correct, it should be 21

Eduardo M. Hernandez  Nov 07, 2022 
Page 611
(3)

Original: The JVM switches between the new thread (user thread A) and the original main thread, until both threads complete.

Problem: Caption on figure next to #3 says, 'user thread "t"'

Possible fix: Change text in parentheses to (user thread "t") for consistency.

Note from the Author or Editor:
Yes, text should be (user thread "t")

Jørgen Lang  Nov 10, 2022 
Page 614
Terminal image at the bottom of the page

Error: annotations are pointing to the wrong dumpStack() call output in the terminal image.

Fix: "dumpStack() called from doMore() in MyRunnable" annotation should point to the output in the terminal that "dumpStack() called from main() method" annotation is pointing to.

Note from the Author or Editor:
Oh my God it's true. Yes.

Annotation "dumpStack() called from doMore() in MyRunnable" should point to the BOTTOM stack trace.

Annotation "dumpStack() called from main() method" should point to the TOP stack trace.

Eduardo M. Hernandez  Nov 09, 2022 
Page 629
code example, bottom right annotation, 2nd sentence

Original: If this method hits the timeout before everything has finished, it returns "false."
Problem/Question: In contrast to the rest of the book, false is placed in quotes. Readers might confuse this with a String type instead of a boolean.
Possible fix: add 'boolean' to clarify, or omit the quotes for more consistency.

Note from the Author or Editor:
Agreed. Omit quotes.

Jørgen Lang  Oct 28, 2022 
Page 657
Bottom terminal window

Error: the output in the terminal that says "Sorry Monica, you can't buy this" should be "Sorry Monica, you haven't spent the money." to match what the previous code example will print in that case.

Eduardo M. Hernandez  Nov 11, 2022 
Page 674
list of new things in code kitchen, #2 "Networking"

Original: NETWORKING: Just like the SimpleChatClient in this chapter, the BeatBox now connects to the server and gets an input and output stream.

Problem: The most current version of the SimpleChatClient is in chapter, not the appendix.

Possible fix: Change prose to: NETWORKING: Just like the SimpleChatClient in chapter 17, the BeatBox now connects to the server and gets an input and output stream.

Note from the Author or Editor:
Agree with suggested fix.

Jørgen Lang  Nov 03, 2022 
Page 676
3rd annotation

Original: This layout manager one lets you [...].

Problem: 'one' has no context.

Suggested fix: Omit 'one'

Note from the Author or Editor:
Confirmed: delete "one"

Jørgen Lang  Nov 03, 2022 
Page 699
left column, last line + right column 2nd para, 2nd sentence

Original:
Left column: "[…] the full code, including implementation, is 41 lines!"
Right column: "That’s all you need to do to replace the 42 lines of
code of the “old” Customer data class."

Problem/Question: 41 or 42? Being a Douglas Adams fan, I know what I'd prefer……

Note from the Author or Editor:
Oh it's true! Yes it should be 42 in both places.

Jørgen Lang  Nov 08, 2022 
Page 711
left column, 10th entry

Original: not equals (!equals and !) 151

Problem: "!equals" should really be "!="

Fix: not equals (!= and !) 151

Note from the Author or Editor:
Should indeed be !=

Jørgen Lang  Nov 11, 2022