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 77
Change “you need place them” to “you need to place them”
Page 81
private ArrayList<Member> members;
private ArrayList<Member> members = new ArrayList<>();
Page 81
Change myFace.enroll("fred") into myFace.enroll("Fred")
Page 96
Change “this code get the average” to “this code gets the average”
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 112
Change “methods such Stream.toArray” to “methods such as Stream.toArray
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 144
Change “and it also rarely necessary” to “and also rarely necessary”
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 237
Change Collection<K> values() to Collection<V> values()
Page 241
Change Bitset to BitSet (4x)
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 262
List<Locale>> englishLocales = englishAndOtherLocales.get(true);
List<Locale> englishLocales = englishAndOtherLocales.get(true);
Page 263
Change Map<String, City> stateToLargestCity to Map<String, Optional<City>> stateToLargestCity
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 281
PrintWriter out = new PrintWriter(outStream, "UTF-8");
PrintWriter out = new PrintWriter(new OutputStreamWriter(outStream,
and remove the sentence that follows.
Page 281
Change “for reading number” to “for reading a number”
Page 284
FileChannel =;
FileChannel channel =;
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 306
Change “the old version on your class” to “the old version of your class”
Page 312
Change “for execution a sequence” to “for executing a sequence”
Page 315
Change “you'd like cancel” to “you'd like to cancel”
Page 337
Change “These two methods throws” to “These two methods throw”
Page 339
Change “instances of NumberFormat class is not threadsafe” to “the NumberFormat class is not threadsafe”
Page 340
Change the entry for anyOf from “Complete with void result after any of the given futures completes.” to “Complete after any of the given futures completes and yield its result.”
Page 346
Change builder.redirectIO() to builder.inheritIO()
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”
Page 408
Change “such the trademark symbol” to “such as the trademark symbol”
Page 408
Change “into a normalized forms” to “into normalized forms”
Page 408
Add a semicolon after String template = "{0} has {1} messages"
Page 411
Change “pass Locale.getDisplayDefault() as the locale” to “pass Locale.getDefault(Locale.Category.DISPLAY) as the locale”

Thanks to Craig Artley, Lorenzo Bettini, Andrew Binstock, Richard Boyd, Rogerio Brioschi, Jean-Paul Dubois, Scott Firestone, 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:
* =