Java for the Impatient

Bug Report Page


How to Tell which Printing You Have

On the bottom of the copyright page (facing the first page of the table of contents), look for a line such as
First printing, January 2015

In the errata below, we indicate the printing in which the error has been fixed inside square brackets such as [4].

For example, suppose you have the fourth printing. Then you can ignore all reports that are prefixed with [2], [3] or [4]. But you would want to pay attention to all reports that are prefixed with [5] or higher or that have no bracketed prefix at all.

Page 1
Change “five integral types, two floating-point types, and boolean” to “four integer types, two floating-point types, char, and boolean."
Page 17
char next = (char)('J' + 1); // Converts 75 to 'K'
int n = 1;
char next = (char)('J' + n); // Converts 75 to 'K'
Page 18
Change “There are two right shift operators: >> fills the top bits with zero, and >>> extends the sign bit into the top bits.” to There are two right shift operators: >> extends the sign bit into the top bits, and >>> fills the top bits with zero.
Page 34
done = false;
done = true;
Page 34, 35
Change if (n < 0) continue; to if (input < 0) continue;
Page 44
Change 3, 10, 11, 8 to 5, 10, 11, 8
Page 49 Exercise 7
Change 65535 to 4294967295, short to int, int to long, and “computes” to “computes and displays”
Page 50
Change 3 10 11 8 to 5 10 11 8
Page 76
Change “package scope” to “package access” (3x)
Page 81
private ArrayList<Member> members;
private ArrayList<Member> members = new ArrayList<>();
Page 81
Change myFace.enroll("fred") into myFace.enroll("Fred")
Page 108
int difference = first.length() < second.length();
change the < operator to a - operator.
Page 108
Add a semicolon at the end of
Runnable task = () -> { for (int i = 0; i < 1000; i++) doWork(); }
Page 117
Change public class Application() to public class Application
Page 120
return (x, y) ->, y);
return (x, y) ->, x);
Page 123
Add a semicolon after the } that lines up with return
Page 137
public class ConcurrentWorker extends Greeter
public class ConcurrentWorker extends Worker
Page 138
Change “the null-safe alternative Object.equals(obj, other)” to “the null-safe alternative Objects.equals(obj, other)
Page 141
Change “Since the equals method overrides Objects.equals” to “Since the equals method overrides Object.equals
Page 150
Change public Modifier() { to Modifier() {
Page 162
Change obj.getDeclaredField("salary") to obj.getClass().getDeclaredField("salary")
Page 184
ex.printStackTrace(new PrintStream(out));
Page 187
Change to Logger.getGlobal()
Page 205
printAll(employees, e -> e.toString().length() % 2 == 0);
Predicate<Object> evenLength = e -> e.toString().length() % 2 == 0;
printAll(employees, evenLength);
Page 209
Change “In this section, you will what goes on” to “In this section, you will see what goes on”
Page 210
public void add(String e)
public boolean add(String e)
public void add(Object e) {
    add((String) e);
public boolean add(Object e) {
    return add((String) e);
Pages 218 and 224
public static <V, T> V doWork ... 
public static <V, T extends Throwable> V doWork ...
Page 229
In the first row of Table 7-2, change the second and fourth add to addAll.
Page 241
byte[] toByteArray[] 
long[] toByteArray[]
byte[] toByteArray()
long[] toLongArray()
Page 244
Change “then Arrays.asList(a) returns a List<T>” to “then Arrays.asList(a) returns a List<E>
Page 246 Exercise 6
Change “Why can’t you use a Map<String, Set<Integer>> to represent a table of contents? (Hint: How would you initialize it?) What type can you use instead?” to:
Suppose you have a method parameter of type Map<String, Set<Integer>>, and someone calls your method with a HashMap<String, HashSet<Integer>>. What happens? What parameter type can you use instead?
Page 255 and in the index (p. 458, 468)
Change getOrElse to orElse
Page 259
Change “You can call the iterate method” to “You can call the iterator method”
Page 260
Change “sum, average” to “sum, count, average” (2x)
Page 260
In the last code sample, change the second
loc -> loc.getDisplayLanguage(loc),
Page 268
Change “is to use stay away” to “is to stay away”
Page 268
.filter(s -> s.length() < 10)
.filter(s -> s.length() < 12)
Page 290
Change “2. When a file or directory is encountered:” to “2. When a file is encountered:”
Page 302
Employee peter = new Employee("Fred", 90000);
Employee paul = new Manager("Barney", 105000);
Employee peter = new Employee("Peter", 90000);
Employee paul = new Manager("Paul", 105000);
Page 337
Change “These two methods throws” to “These two methods throw”
Page 381
Change “by calling toNanos, toMillis, toSeconds, toMinutes” to “by calling toNanos, toMillis, getSeconds, toMinutes
Page 405
Change the caption of Table 13-4 to “Date and Time Formatting Styles”

Thanks to Craig Artley, Lorenzo Bettini, Andrew Binstock, Richard Boyd, Rogerio Brioschi, Jean-Paul Dubois, Mikhail Firulin, Ian Gatenby, Lukasz Gorski, Tigran Gularyan, Ben Hadley, Garrett A. Hughes, Alain Kreienbuhl, Tony Mathson, Aleksandr Morozov, Christoph Nahr, Stiu Principle, Hans-J. Schmid, Raj Karan Singh, Andrzej Stefanski, Matt Stavola, David Thiele, Suleiman Khan Tischhauser, Serguei Yanush, Mark Zarins, and (your name might go here) for their bug reports and suggestions!

Bug Report Form

Please use this form to report any bugs that you find. Please check the list of known bugs first before you report a bug. Unfortunately, I do not have the time to respond personally to every report, but I do read them all and will post updates to this page. Thank you!

Your name:

Your email address:

Page number:

Problem description:

To protect against spam robots, please answer this simple math problem:
* =