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.
\u00A0
to \u000A
.http://docs.oracle.com/javase/8/docs/api
(Figure 3.2).”for
loop in C++ and the foreach
loop in C#.”1
for Monday” to “1
for Monday”java.util.LocalDate
, change LocalTime
to LocalDate
(2x)
LocalDate hireDay = LocalDate.of(year, month, day);to
hireDay = LocalDate.of(year, month, day);
LocalDate hireDay = LocalDate.now(year, month, day);to
hireDay = LocalDate.of(year, month, day);
Employee(String name, double salary, int y, int m, int d)to
public Employee(String n, double s, int year, int month, int day)
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.*;
”super(n, s, year, month, day);to
super(name, salary, year, month, day);
Object.equals(hireDay, other.hireDay)
to Objects.equals(hireDay, other.hireDay)
equals
, hashCode
, and toString
methods” to “The program in Listing 5.8 tests the equals
, hashCode
, and toString
methods”return super.hashCode() + 17 * new Double(bonus).hashCode();to
return java.util.Objects.hash(super.hashCode(), bonus);
void set(int index, E obj)
to E set(int index, E obj)
and “overwriting the previous contents” to “returning the previous contents.”public enum Size { SMALL, MEDIUM, LARGE, EXTRA_LARGE }
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(); } }
Objects.equals
to Object.equals
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(); } }
public class Application()
to public class Application
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.”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"))
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)
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(); }
DateInterval.setSecond(Date)
, which is what we want.” to “It calls DateInterval.setSecond(LocalDate)
, which is what we want.”for (t : ts) coll.add(t);to
for (T t : ts) coll.add(t);
names
(that is, String[]
) against the generic type
T[]
” to “It matches the type of the arguments against the generic type
T...
”PairAlg.swap(result); // OK--swapHelper captures wildcard typeto
PairAlg.swapHelper(result); // OK--swapHelper captures wildcard type
return = true;
to return true;
boolean add(Object element)
to boolean add(E element)
Iterator iter
to Iterator<String> iter
System.println
to System.out.println
descripion
to description
in the toString
method.E pollLast
to E pollLast()
@version 1.01 2012-01-26
to @version 1.02 2015-06-20
int score = scores.get(id, 0);
to int score = scores.getOrDefault(id, 0);
@version 1.11 2012-01-26
to @version 1.12 2015-06-21
null
).”, and add the following to the API note:
default V putIfAbsent(K key, V value)
8If key
is absent or associated with null
, associates it with value
and returns null
. Otherwise returns the associated value.
}();
to };
List group2
to List<Employee> group2
get
and put
are serialized” to “The methods such as
get
and put
are synchronized”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”Collections.replaceAll("C++", "Java");
to Collections.replaceAll(words, "C++", "Java");
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(); . . . }
@version 1.33 2007-05-12
to @version 1.34 2015-06-16
@version 1.33 2007-05-12
to @version 1.34 2015-06-16
Rectangle2D bounds = sansbold14..getStringBounds(message, context);to
Rectangle2D bounds = sansbold14.getStringBounds(message, context);
faceCombo.getItemAt(faceCombo.setSelectedIndex()),to
faceCombo.getItemAt(faceCombo.getSelectedIndex()),
cutAction.putValue(Action.MNEMONIC_KEY, new Integer('A'));to
aboutAction.putValue(Action.MNEMONIC_KEY, new Integer('A'));
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();
”ExecutionException
” to “wrapped in an ExecutionException
”PrintWriter out = new PrintWriter( new FileOutputStream("employee.txt"), "UTF-8");to
PrintWriter out = new PrintWriter( new FileOutputStream("employee.txt"), false, "UTF-8");
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 into
read the contents of zin
/opt/myXapp/temp
to /opt/myapp/temp
InterruptedIOException
to SocketTimeoutException
(2x)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!
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.
Back to the Core Java page.