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 2021”. 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.
if (Character.isSupplementaryCodePoint(cp)) i += 2; else i++;to the simpler
i += Character.charCount(cp);
java.io..Console
static
from readPassword
and readLine
i
th integer” to “the integer with index i
”int n = Employee.getNextId();to
int n = Employee.advanceId();
The this
reference in Java is identical to the this
pointer in C++. However, in C++, you call another constructor in the member initialization list:
Employee(double s) : Employee("Employee #" + nextId, s) { nextId++; }
is shorthand for “call the constructor of the Employee
superclass with n
, s
, year
,
month
, and day
as parameters”
is shorthand for “call the constructor of the Employee
superclass with name
, salary
, year
, month
, and day
as arguments”
javac resource/ResourcesTest.java
to javac resources/ResourcesTest.java
java.lang.Class
getDeclaredField
returns an array” to “getDeclaredFields
returns an array” default String getName() { return ""; }
As of Java 16, inner classes can have static
members. Previously, static
methods in inner classes were disallowed, and static fields declared in an inner class had to be final and initialized with a compile-time constant.
Static methods of an inner class can access static fields and methods from the inner class or enclosing classes.
java.lang.StackWalker.StackFrame
, change String getDeclaringClass()
to Class<?> getDeclaringClass()
java -ea:MyClass -ea:com.mycompany.mylib MyAppto
java -ea:MyClass -ea:com.mycompany.mylib... MyAppand “The option
-ea...
turns on” to “The option -ea:...
turns on”Lock lock = new Object();
to Object lock = new Object();
private static Holder
to private static class Holder
java.util.concurrent.ConcurrentSkipListMap<K, V>
ConcurrentSkipListSet<K, V>(Comparator<? super K> comp)
to ConcurrentSkipListMap<K, V>(Comparator<? super K> comp)
Arrays.parallelSort(words.length / 2, words.length)
to Arrays.parallelSort(words, words.length / 2, words.length)
executors/ExecutorDemo.java
+ tpExecutor.getLargestPoolSize());
sentence.codePointAt(i)
to s.codePointAt(i)
(2x)if (Character.isSupplementaryCodePoint(cp)) i += 2; else i++;to
i += Character.charCount(cp);
collector.accept(cp);to
collector.accept(new String(new int [] { cp }, 0, 1));
int cp = sentence.codePointAt(i);
to int cp = s.codePointAt(i);
new Result(list, avg)
to new Pair(list, avg)
java.io.InputStream
readNBytes
remove “, or -1 at the end of the input stream”FileChannel = FileChannel.open(path);to
FileChannel channel = FileChannel.open(path, StandardOpenOption.WRITE);
employees[i] = new Employee();
and change
employees[i].readData(in);to
employees[i] = readEmployee(in);
randomAccess/RandomAccessTest.java
newStaff[i] = new Employee();
, change
newStaff[i] = readData(in);to
newStaff[n - 1 - i] = readData(in);and
new Employee(name, salary, y, m - 1, d)to
new Employee(name, salary, y, m, d)
visitFileFailed
do nothing and continue.” to “”java.net.URLConnection.getHeaderField
, change “or null
if n
is < 0
” to “or the response status line if n
is 0 or null
if n
is < 0
”Optional<String> lastModified = headerMap.firstValue("Last-Modified");to
Optional<String> lastModified = responseHeaders.firstValue("Last-Modified");
client/HttpClientTest.java
ofMimeMultipartData
method, change all \n
to \r\n
, and add
byteArrays.add(bytes("\r\n"));below
byteArrays.add(Files.readAllBytes(path));
Thanks to Umesh Berry, Dariusz Daćko, Ahmad Elkomey, Piyush Gupta, Zak Harris, Randy Henderson, Shao Jun, Oleksii Klochko, Suresh Kumar, Toreno Li, Saransh Mundepi, Marek Nowicki, Sy Pham, Nirav Pradhan, Satishchandra Singh, Zheng Song, Mingbao Sun, Eugene Shpak, Tommy Thomas, Jiulong Wang, Xiangaho Wang, Hongyuan Zhang, Liang Zhao, 冯橹宇, 黄兆彬, and (your name might go here) for their bug reports!
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.