Java Methods A & AB, Second Printing Errata ===========================+======== p. 32, Figure 2-7: Comments are out of sync with the code. should be: // corner at x = 20, y = 40: ... // Draw a string of text starting at x = 55, y = 65: ... // upper-left corner at 300, 300; width 200, height 150 p. 186, first paragraph: Collect all the files for the Craps program together: Craps.jar (from JM\Ch07\Craps); ... should be: Collect all the files for the Craps program together: Craps.jar and Craps.java (from JM\Ch07\Craps); ... p. 205, first paragraph: The 44th Mersenne prime, 2^32,582,657 - 1 = 12457502601536945540... 11752880154053967871 (9,808,358 digits), was discovered in September 2006. p. 485 Figure 19-15, p. 488 Figure 19-18 and p. 491 Table 19-2 Note: ==== Strictly speaking, the parameter in Set's contains and remove methods is specified in Java API as Object, not E. Likewise, the parameter in Map's containsKey, get, and remove methods is Object, not K. We find this design unfortunate, confusing for a novice, and potentially dangerous, as these methods can throw a ClassCastException for TreeSet and TreeMap, if called with a parameter other than an instance of E or K, respectively. Our Figure 19-15, Figure 19-18, and Table 19-2 list incorrect signatures for these methods, but we hesitate to change that. Java Methods A & AB, First Printing Errata =================================== p. 70, Question 6: 100 pixels should be: 160 pixels p. 162, first line: then binary operators should be: than binary operators p. 182, bottom: myGrade == Exam.LetterGrade.A; should be: myGrade = Exam.LetterGrade.A; p. 210, Question 14: 30 cents = 0 quarters + 2 dimes + 1 nickels + 0 pennies should be: 30 cents = 0 quarters + 2 dimes + 1 nickels + 5 pennies p. 253, Question 11: java.util.Rectangle _______ should be: java.awt.Rectangle _______ p. 268, Line 8: int pos1 = s.IndexOf("e"); // pos1 gets the value 3 should be: int pos1 = s.indexOf("e"); // pos1 gets the value 3 p. 335, middle: String names = {"Alice", "Bob", "Claire"}; should be: String[] names = {"Alice", "Bob", "Claire"}; p. 357, Question 17: char[] hello = {' ', 'h', 'e', 'l', 'l' 'o'}; should be: char[] hello = {' ', 'h', 'e', 'l', 'l', 'o'}; p. 368, first line: if an only if should be: if and only if p. 375, last paragraph: Save the current size of the list, then append to it n arbitrary strings, where n = additionalWords.size(). Call super.add("") to append an empty string at the end of the list or just call addAll(additionalWords) once. should be: Find the number of additional words to be inserted. To do that efficiently, do a "tentative merge" without moving any elements. Then save the current size of the list and append to it the required number of arbitrary strings. Call super.add("") to append an empty string at the end of the list. p. 463, Question 6: for (int i = k; i < k + n; k++) should be: for (int i = k; i < k + n; i++) p. 474, third line: list.size() should be: movies.size() p. 474, second code fragment: ListIterator iter1 = movies.iterator(); should be: ListIterator iter1 = movies.listIterator(); p. 488, Figure 19-18 and p. 491, Table 19-2: boolean containsKey() should be: boolean containsKey(K key) p. 502 Question 10: stk.push(cursor.getX())); stk.push(cursor.getY())); should be: stk.push(cursor.getX()); stk.push(cursor.getY()); p. 524 Question 5: head refers to the fist should be: head refers to the first p. 543 Question 3: public class ListNodeStack implements Stack should be: public class ListNodeStack p. 612, 5th line: hashTable[index].setValue(target.getValue()); should be: hashTable[index] = target;