Thank you.
-
Chapter 1, page 71:
Annotation for the last line of code in method main, class DowncastWithImplicitCasting should read:
Okay--a ShoppingItem is an Object.
-
Chapter 1, page 90:
Option (a) and (b) in Q 1-8 should read:
(a) Class Color overrides method toString() appropriately.
(b) Class Color overriddes method equals() appropriately.
-
Chapter 1, Page 92:
First line in explanation to answer 1-8, should read:
Class Color overrides method toString() appropriately, but not method equals().
-
Chapter 2, Page 108:
For the following code:
class Publisher{
public static void main(String args[]){
System.out.println(Book.bookCount);
Book b1 = new Book();
Book b2 = new Book();
System.out.println(Book.bookCount); // Changes to annotation for this line
b1.bookCount = 10;
System.out.println(b2.bookCount);
}
}
Code annotation for the second instance of System.out.println(Book.bookCount)
should read:
Prints 2 (access bookCount using class name Book)
- Chapter 2, Pg 121:
contains90 in the last paragraph should be contains().
- Chapter 3, page 234:
In Q3-20, Option (e) should read:
DateFormat.getDateInstance()
- Chapter 4, page 250:
The first line of section 'NONGENERIC CLASS EXTENDING A GENERIC CLASS':
You can extend a generic base class to define a nongeneric base class.
should be:
You can extend a generic base class to define a nongeneric child class.
- Chapter 4, page 265:
In the following code:
class Parcel<T> {
public <X> void deliver(X x) {
System.out.println(x.getClass());
}
public static void main(String args[]) {
Parcel<String> parcel = new Parcel<>();
parcel.<Integer>deliver(10);
//parcel.<>deliver(new Integer(10));
parcel.deliver("Hello");
}
}
The following line of code:
parcel.<Integer>deliver(new Integer (10));
should be:
parcel.<Integer>deliver(10);
Its corresposning annotation:
Type of parameter X is Integer; determined using Integer object passed to deliver().
should be:
Type of parameter X is Integer; passed as explicit type parameter value. byte value 10 is boxed to Integer.
The following assignment is allowed (with compiler warning):
Parcel parcel = new Parcel<Phone>();
But you lose the type information for the class Parcel in the preceding code. Again, when you call its method set() (passing it a method parameter of any type), you'll get a compiler warning:
- Chapter 4, page 265:
Question 4-4, answer option (c):
Calling clear() and remove() on an ArrayList will remove all its elements.
should be:
Calling clear() or remove() on an ArrayList will remove all its elements.
- Chapter 4, Page 266:
Here's how the first few paragraphs of section 4.4.1 should read:
An attempt to compile code that mixes reference variables and objects of raw and generic types will generate compiler warning. However, depending on whether a warning is enabled on your JVM, your compiler might or might not display the warning. Consider the following generic class:
class Parcel<T> {
private T t;
public void set(T t) {
this.t = t;
}
public T get() {
return t;
}
}
- Chapter 4, page 283:
In figure 4.17, the method 'peer' listed under the Queue methods, used to work with Deque as a FIFO data structure, should be 'peek'.
- Chapter 4, page 285:
In figure 4.19, Deque methods used to add, remove, and query elements at both its ends:
Add elements to head
-------------addFirst(E)
-------------offerFirst(E)
-------------bush(E)
should be:
Add elements to head
-------------addFirst(E)
-------------offerFirst(E)
-------------push(E)
- Chapter 4, page 285:
In figure 4.19,
Remove at random position
-------------contains(Object o)
-------------size()
should be:
Query
-------------contains(Object o)
-------------size()
- Chapter 4, Page 297
The last two lines of code:
Map<String, Double> salaryMap = new HashMap<>();
Map<String, Object> copySalaryMap = new HashMap<>(salaryMap);
should be:
Map<String, Double> salaryMap = new HashMap<>();
Map<String, Double> copySalaryMap = new HashMap<>(salaryMap);
- Chapter 9, page 626:
In answer to question 9-8, the text:
When rollback() is called on a Connection object without the savepoint name, it's rolled back to the unnamed savepoint.
should be:
When rollback() is called on a Connection object without passing it a Savepoint object, all uncommited transactions are rolled back.