Welcome to the Core Java Bug List

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, December 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.

10th Edition Volume 1 (Java SE 8)

[2] Page 51
In the Caution note, change \u00A0 to \u000A.
[2] Page 74
Change “The API documentation is part of the JDK. It is in HTML format. Point your web browser to the docs/api/index.html subdirectory of your JDK installation (Figure 3.2).” to “You can download the API documentation from Oracle and save it locally, or you can point your browser to http://docs.oracle.com/javase/8/docs/api (Figure 3.2).”
[2] Page 89
Change “Finally, there is a variant of the for loop that has no analog in C or C++. It is similar to the foreach loop in C#.” to “Finally, there is a variant of the for loop that is similar to the range-based for loop in C++ and the foreach loop in C#.”
Page 143
Change “11 for Monday” to “1 for Monday”
Page 145
In the API notes for java.util.LocalDate, change LocalTime to LocalDate (2x)
[2] Page 150
Change
LocalDate hireDay = LocalDate.of(year, month, day);
to
hireDay = LocalDate.of(year, month, day);
Page 157
Change “the designers of the class can be assured that it is never used outside the other class” to “the designers of the class can be assured that it is never used elsewhere”
Page 162
Change
LocalDate hireDay = LocalDate.now(year, month, day);
to
hireDay = LocalDate.of(year, month, day);
Page 172
Change “there there” to “there”
[2] Page 173
Change
Employee(String name, double salary, int y, int m, int d)
to
public Employee(String n, double s, int year, int month, int day)
[2] Page 178
Replace the numbered list with:
  1. If the first line of the constructor calls a second constructor, then the second constructor executes with the provided arguments.
  2. Otherwise,
    • All data fields are initialized to their default values (0, false, or null).
    • All field initializers and initialization blocks are executed, in the order in which they occur in the class declaration.
  3. The body of the constructor is executed.
[2] Page 183
Change “For example, you can import all classes in the java.util package with the statement import java.util.*;” to “For example, you can import all classes in the java.time package with the statement import java.time.*;
[2] Page 189
Change the section heading “Package Scope” to “Package Access”
[2] Page 189
Change “package visibility” to “package access”
Page 207
Change
super(n, s, year, month, day);
to
super(name, salary, year, month, day);
Page 208
Change “If the subclass constructor does not call a superclass constructor explicitly, the no-argument constructor of the superclass is invoked. If the superclass does not have a no-argument constructor and the subclass constructor does not call another superclass constructor explicitly, the Java compiler reports an error.” to “When a subclass object is constructed without explicit invocation of a superclass constructor, the superclass must have a no-argument constructor. That constructor is invoked prior to the subclass construction.”
Page 227
Change “nama” to “name”
[2] Page 230
Change Object.equals(hireDay, other.hireDay) to Objects.equals(hireDay, other.hireDay)
Page 240
Change “The program in Listing 5.8 implements the equals, hashCode, and toString methods” to “The program in Listing 5.8 tests the equals, hashCode, and toString methods”
[2] Page 243
Change
return super.hashCode() + 17 * new Double(bonus).hashCode();
to
return java.util.Objects.hash(super.hashCode(), bonus);
[2] Page 251
Change void set(int index, E obj) to E set(int index, E obj) and “overwriting the previous contents” to “returning the previous contents.”
[2] Page 258
Remove the semicolon after public enum Size { SMALL, MEDIUM, LARGE, EXTRA_LARGE }
[2] Page 290
Change “package visibility” to “package access”
[2] Page 292
Remove “for sorting an employee array”
Page 296
Change “Although you cannot put instance fields or static methods in an interface” to “Although you cannot put instance fields in an interface,”
[2] Page 300
Change “Consider another interface with a getName method:” to “Consider two interfaces with a getName method:” and change the code below to:
interface Person
{
   default String getName() { return ""; };
}

interface Named
{
   default String getName() { return getClass().getName() + "_" + hashCode(); }
}
Page 302
In the Caution note, change Objects.equals to Object.equals
Page 321
Change the code on top of the page to the (even more contrived)
class Greeter
{
   public void greet(ActionEvent event)
   {
      System.out.println("Hello, " + event);
   }
}

class TimedGreeter extends Greeter
{
   public void greet(ActionEvent event)
   {
      Timer t = new Timer(1000, super::greet);
      t.start();
   }
}
[2] Page 323
Change “It is also illegal to refer to variable” to “It is also illegal to refer to a variable”.
[2] Page 324
Change public class Application() to public class Application
Page 328
Change “The compiler gives an error message if you accidentally add another nonabstract method.” to “The compiler gives an error message if you accidentally add another abstract method.”
Page 335
Change “Any static fields declared in an inner class must be final. ... If the field was not final, it might not be unique.” to “Any static fields declared in an inner class must be final and initialized with a compile-time constant. If the field was not a constant, it might not be unique.”
[2] Page 338
Change “Since the secret access methods have package visibility” to “Since the secret methods have package access”
[2] Page 341
Remove the paragraph “As we already mentioned...always the same value” above the note.
[2] Page 376
Change
try (Scanner in = new Scanner(new FileInputStream("/usr/share/dict/word"), "UTF-8")
to
try (Scanner in = new Scanner(new FileInputStream("/usr/share/dict/words"), "UTF-8"))
[2] Page 378
Change
StackTraceTest.factorial(StackTraceTest.java:18)
StackTraceTest.main(StackTraceTest.java:34)
factorial(2):
StackTraceTest.factorial(StackTraceTest.java:18)
StackTraceTest.factorial(StackTraceTest.java:24)
StackTraceTest.main(StackTraceTest.java:34)
factorial(1):
StackTraceTest.factorial(StackTraceTest.java:18)
StackTraceTest.factorial(StackTraceTest.java:24)
StackTraceTest.factorial(StackTraceTest.java:24)
StackTraceTest.main(StackTraceTest.java:34)
to
stackTrace.StackTraceTest.factorial(StackTraceTest.java:20)
stackTrace.StackTraceTest.main(StackTraceTest.java:36)
factorial(2):
stackTrace.StackTraceTest.factorial(StackTraceTest.java:20)
stackTrace.StackTraceTest.factorial(StackTraceTest.java:26)
stackTrace.StackTraceTest.main(StackTraceTest.java:36)
factorial(1):
stackTrace.StackTraceTest.factorial(StackTraceTest.java:20)
stackTrace.StackTraceTest.factorial(StackTraceTest.java:26)
stackTrace.StackTraceTest.factorial(StackTraceTest.java:26)
stackTrace.StackTraceTest.main(StackTraceTest.java:36)
[2] Page 393
Change “At least up to Java SE 7” to “Up to Java SE 7”.
[2] Page 428
Change “Suppose the DateInterval method also overrides the getSecond method:” to “Suppose the DateInterval class also overrides the getSecond method:”
[2] Page 428
Change
public void setSecond(Object second) { setSecond((Date) second); }
to
public void setSecond(Object second) { setSecond((LocalDate) second); }
and change
public LocalDate getSecond() { return (Date) super.getSecond().clone(); }
to
public LocalDate getSecond() { return (LocalDate) super.getSecond(); }
Page 428
Change “It calls DateInterval.setSecond(Date), which is what we want.” to “It calls DateInterval.setSecond(LocalDate), which is what we want.”
[2] Page 432
Change
for (t : ts) coll.add(t);
to
for (T t : ts) coll.add(t);
Page 447
Change “It matches the type of names (that is, String[]) against the generic type T[]” to “It matches the type of the arguments against the generic type T...
[2] Page 448
Change
PairAlg.swap(result); // OK--swapHelper captures wildcard type
to
PairAlg.swapHelper(result); // OK--swapHelper captures wildcard type
[2] Page 467
Change return = true; to return true;
[2] Page 468
Change boolean add(Object element) to boolean add(E element)
Page 476
Change Iterator iter to Iterator<String> iter
[2] Page 489
Change System.println to System.out.println
[2] Page 492
Change descripion to description in the toString method.
[2] Page 493
Change E pollLast to E pollLast()
[2] Page 496
Change @version 1.01 2012-01-26 to @version 1.02 2015-06-20
[2] Page 497
Change int score = scores.get(id, 0); to int score = scores.getOrDefault(id, 0);
[2] Page 498
Change @version 1.11 2012-01-26 to @version 1.12 2015-06-21
[2] Page 501
Change “ if the key was previously absent” to “ if the key was previously absent (or mapped to null).”, and add the following to the API note:
Page 506
In the second code display, change the last line from }(); to };
[2] Page 510
Change List group2 to List<Employee> group2
[2] Page 513
Change “The methods such as get and put are serialized” to “The methods such as get and put are synchronized”
Page 522
Change “using a linear search if the element type implements the RandomAccess interface, and a binary search in all other cases” to “using a binary search if the element type implements the RandomAccess interface, and a linear search in all other cases”
[2] Page 523
Change Collections.replaceAll("C++", "Java"); to Collections.replaceAll(words, "C++", "Java");
[2] Page 529
Change
Enumeration<Employee> e = staff.elements();
while (e.hasMoreElements())
{
   Employee e = e.nextElement();
   . . .
}
to
Enumeration<Employee> values = table.elements();
while (values.hasMoreElements())
{
   Employee e = values.nextElement();
. . .
}
[2] Page 550
Add a bullet before “You can maximize a frame by calling”
[2] Page 551
Change @version 1.33 2007-05-12 to @version 1.34 2015-06-16
[2] Page 566
Change @version 1.33 2007-05-12 to @version 1.34 2015-06-16
[2] Page 576
Change
Rectangle2D bounds = sansbold14..getStringBounds(message, context);
to
Rectangle2D bounds = sansbold14.getStringBounds(message, context);
[2] Page 670
Change
faceCombo.getItemAt(faceCombo.setSelectedIndex()),
to
faceCombo.getItemAt(faceCombo.getSelectedIndex()),
[2] Page 680
Change “When the user selects a menu” to “When the user selects a menu item”.
[2] Page 686
Change
cutAction.putValue(Action.MNEMONIC_KEY, new Integer('A'));
to
aboutAction.putValue(Action.MNEMONIC_KEY, new Integer('A'));
[2] Page 707
Change "The GBC helper class is in Listing 12.12" to "The GBC helper class is in Listing 12.11"
[2] Page 889
Change “must have must have” to “must have”
Page 908
Remove “Since putIfAbsent returns the mapped value (either the existing one or the newly put one), you can combine the two statements: map.putIfAbsent(word, new LongAdder()).increment();
[2] Page 933
Change “wrapped in an unchecked ExecutionException” to “wrapped in an ExecutionException

10th Edition Volume 2 (Java SE 8) ???

Page 60
Change
PrintWriter out = new PrintWriter(
   new FileOutputStream("employee.txt"), "UTF-8");
to
PrintWriter out = new PrintWriter(
   new FileOutputStream("employee.txt"), false, "UTF-8");
Page 77
Change “Pass the entry to the getInputStream method of the ZipInputStream to obtain an input stream for reading the entry. ” to “Read from the stream until the end, which is actually the end of the current entry. ” Change
    InputStream in = zin.getInputStream(entry);
   read the contents of in
to
   read the contents of zin
Page 102
Change /opt/myXapp/temp to /opt/myapp/temp
Page 238
Change “If the timeout value has been set for a socket, all subsequent read and write operations” to “If the timeout value has been set for a socket, all subsequent read operations”
Page 239
Change InterruptedIOException to SocketTimeoutException (2x)
Page 891
Change catch (UnsupportedFlavorException e | IOException ex) to catch (UnsupportedFlavorException | IOException ex)

Thanks to Maxim Belyaev, Aaron Chen, Dharm Balian, Yasir Bajwa, Maxim Belyaev, Jeff Carbonneau, Wing Ming Chan, Zuo Cheng, Aleksey Chudov, Alexey Elin, Gianni Fabriziani, Daniel Fishman, Pavlo Gotsonoga, Dominik Gruntz, M. Henry, Detlef Herm, In Soo Jang, Justin Jia, Franklin Dale Jones, Suresh Kumar, Stevens R Miller, Konstantin Nasibulin, Paul Orekhov, Patrick O'Brien, Park Young-Ju, Nirav Pradhan, Frid Ruland, Dharmesh Sujeeun, Akos Varga, Sergey Vaysman, Tony Verkamp, Liutauras Vilda, Joyce Wang, Henry Ying, Mehran Zare, Gaopeng Zhang, Joy Zhang, Qiling Zhao, Wudong Zhou, 陈栩林, and (your name might go here) for their bug reports!

Bug Report Form

If you have found another bug in the book or in our code that is not mentioned in this bug list or the Core Java FAQ , then please send a report. Unfortunately, I cannot reply personally to each report, but I do read all your comments.

Your name:

Your email address:

Edition:
Page number:

Problem description:

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


Back to the Core Java page.