Errata for Computing with Java: Second Edition Copyright 2001, Art Gittleman p. xi Line 20 Change "Chapter 2" To "Chapter 6" p. xiii Add Web Site My web site for this book is at http://www.cecs.csulb.edu/~artg/cwj/ where an errata list will be posted. Please send any typos or other errors to me directly at artg@csulb.edu. p. 11 Line 8 from the bottom Change "and 300" To "as 300" p. 14 Bottom line Change "wait" To "waits" p. 15 Line 13 Change "program continues executing" To "system continues executing" p. 20 Line 16 Change "needed needed" To "needed" p. 29 Figure 2.3 Change "size" To "speed" p. 42 Line 9 Change "then" To "then 3 + x." p. 54 Line 12 Change "("The result" To "(null, "The result" p. 56 Line 18 Change "left" To "right" p. 68 Line 2 Change "3 < = 4 is" To "3 <= 4 is" p. 71 Example 3.2 p. 75 Example 3.3 Add as the last line of the main method "System.exit(0);" p. 83 Note 5 Change "between between" To "between" p. 93 After line 7 Add "}" p. 111 Line 9 from the bottom Change "draw" To "g.draw" p. 114 Exercise 39 Change "16" To "38" p. 115 Line 22 Omit the sentence starting "We added methods.." p. 116 Line 12 Change "corner" To "each corner" p. 116 Problem 2a Change "3/2" To "3.0/2" p. 118 Line 15 Change "total")" To "total)" p. 119 Exercise 13 Change "7.4957181" To "7.4957" Change "14.109587" To "14.1096" p. 124 Line 8 Change "character" To "char" p. 139 Bottom line Change "4.13" To "4.16" p. 141 Lines 23 and 29 Change "item" To "number" p. 142 After line 20 Add "System.exit(0);" p. 146 Exercise 11 Align "else" under the first "if" p. 154 Add at top "import javax.swing.*; import java.text.*;" p. 160 Add at top "import javax.swing.*"; p. 172 Line 7 Change "while" To "} while" p. 184 Bottom line Change "once" To "one" p. 189 Change Line 7 to String input = JOptionPane.showInputDialog ("Enter the amount of Product A sales"); double salesOfA = Double.parseDouble(input); p. 189 Change Line 8 to input = JOptionPane.showInputDialog ("Enter the amount of Product B sales"); double salesOfB = Double.parseDouble(input); p. 189 Change lines 20 and 21 to NumberFormat nf = NumberFormat.getCurrencyInstance(); System.out.println("The commission is " + nf.format(amount)); System.exit(0); p. 192 Problem 27 Change "< 1" To "< .25" p. 193 Line 5 from the bottom Change "let" To "lets" p. 197 Line 11 of Figure 5.4 Change "ch" To "str" p. 198 Line 11 from the bottom Change "objects." To "objects. " p. 198 Line 8 from the bottom Change "OBJECTS. " To "OBJECTS. " p. 199 Line 6 from the bottom Change "edit" To "exit" p. 199 Indent the bottom line eight spaces p. 200 Line 3 Indent "I like .." eight spaces instead of 2 p. 201 Figure 5.6 Change "my String" To "myString" p. 204 Exercise 2 Change "Strings" To "String s" p. 206 Figure 5.12 Change "place an order pay" To "place an order pay" p. 208 Line 14 Change "aCustomer, aWaiter, and aCook" To "fred, suzy, and joe" p. 212 Lines 20 and 21 Omit "discussed in Chapter 3," p. 220 Before Line 2 from the bottom Add "NumberFormat nf = NumberFormat.getCurrencyInstance();" p. 228 Figure 5.26 Change the last "serve burger" To "serve fries" p. 230 line 9 from the bottom Change ";;" To ";" p. 232 Note 7 Change "Cook cook" To "Cook joe" p. 233 Figure 5.29 Address Change to: street : String city : String state : String zip : String p. 236 bottom line p. 237 lines 1 and 2 Change "l" To "len" p. 238 Omit Note 8 p. 240 Line 10 Change "amount method of Example 1.6" To "getTransactionCount method of Example 5.5" p. 246 Line 2 Change "are" To "our" p. 250 Line 5 from bottom Change "//.java" To "//java" p. 251 Line 13 from the bottom Change "Explorer ," To "Explorer, " p. 253 Line 6 Omit " "HelloWorld!" " p. 255 Line 12 from the bottom Change "(20, 30)" To "(30, 30)" p. 259 Line 2 Change "differ ent" To "different" p. 260 Note 6 Change "Serif" To "Arial" p. 262 Line 15 Change the last "255" To "255)" p. 263 Note 2 Change "return" To "returns" p. 268 Add a blank line after the first three lines of Output p. 270 Line 7 Change "county" To "country" p. 267 Line 4 Change "variable" To "variables" p. 271 Line 3 from the bottom Change "respons" To "responds" p. 272 Line 13 Change "send" To "sends" p. 273 Exercise 22 Change "customer.study" To "customer1.study" p. 273 Exercise 22 Omit "in the concertComing method" p. 275 Bottom line Change "Chapter 6" To "Chapter 7" p. 283 Line 2 from the bottom Change "border, grid, and gridbag layouts" To "border, and grid layouts" p. 284 Line 8 Change "illustrate to" To "illustrate" p. 289 Question 2 Change "and are" To "and which are" p. 290 Line 14 Change "interest rate" To "concert schedule" p. 304 Lines 6, 8, 10, and 12 p. 307 Lines 10, 12, and 14 from the bottom Change "color" To "Color" p. 304 Lines 7 and 9 p. 307 Lines 13 and 15 from the bottom Change "color.getSelectedItem1)" To "color.getSelectedItem()" p. 306 Line 7 from the bottom Omit "as in Example 7.7" p. 307 Omit lines 10 and 11 p. 307 Add Color c; as the first line of the paint method. p. 316 Lines 6-10 Change "mess .append" To "mess.append" p. 318 Note 6 Change "salects" To "selects" p. 334 Line 9 from the bottom Change "8.11b show" To "8.11b shows" p. 336 Line 11 Change "Io.readInt("Enter an integer");" To "Integer.parseInt (JOptionPane.showInputDialog("Enter an integer"));" p. 344 Figure 8.20 Change "JoptionPane" To "JOptionPane" p. 351 Bottom Line Add a new line "private Random random = new Random();" p. 352 Line 18 Change "dice.tossResults" To "tossResults" p. 361 Line 19 from the bottom Change "Sors" To "Sorts" p. 363 Line 11 from the bottom Change "Chapter 6" To "Chapter 8" p. 364 Line 4 from the bottom Change "runtimne" To "runtime" p. 381 Line 2 from the bottom Change "Io.readInt("How many characters?");" To "Integer.parseInt(JOptionPane.showInputDialog ("How many characters?"));" p. 382 Line 2 Change "Io.readChar("Enter next character");" To "JOptionPane.showInputDialog("Enter next character") .charAt(0);" p. 382 Problem 13b Change "of to" To "of part a to" p. 388 Top line Change "form" To "from" p. 388 Lines 5 and 8 Change "SimpleSaving1" To "SimpleSavings1" p. 389 Line 5 from the bottom Change "SimpleSaving2" To "SimpleSavings2" p. 402 Line 6 Change "UseNewAnimals.java" To "UseNewAnimal.java" p. 409 Example 9.12 Add a closing right brace, }, at the end of the code. p. 410 Figure 9.11 Change "move(x,y)" To "move(xAmount,yAmount)" p. 413 Change Note 7 To "s[0] = new Line(20,50,60,70); The line has coordinates (20,50) and (60,70)." p. 416 Line 8 from the bottom Change "book\r" To "book1r" p. 416 Line 24 Change "contain" To "contains" p. 418 Line 11 Change "dradius" To "radius" p. 419 Line 11 Change "3.3" To "9.12" p. 426 Line 7 Change "accoutn" To "account" p. 427 Remove the extra "Figure9.21 label p. 431 Line 28 Change "intacct" To "int acct" p. 436 Line 9 from the bottom Change "21-24" To "19-22" p. 448 Lines 15, 16, 17, and 27 Omit the semicolon at the end of the line. p. 477 Line 15 Change "f " To "if " p. 480 Lines 9 and 10 Change ".Math" To "Math" p. 485 Line 2 from the bottom Change "keyPressed" To "keyTyped" p. 505 Line 17 from the bottom Omit "Enter an index from 0 to 2: 98" p. 513 Line 15 from the bottom Change ".10" To "2.10" p. 515 Line 22 Change "TotalCost.data" To "totalCost.data" p. 515 Line 6 from the bottom Change "form" To "from" p. 518 Before line 12 from the bottom Add "import java.io.*;" p. 540 Line 14 from the bottom Changed "numbers" To "number" p. 544 Line 10 Change "be" To "by" p. 547 Line 3 from the bottom Change "use" To "used" p. 550 Line 17 Change "selected" To "selections" p. 565 Line 9 Change "JPanel" To "JFrame" p. 566 Line 14 Change "tables" To "table" p. 572 Lines 8-9 from the bottom Change "asking" To "ask" p. 580 Line 14 Change "8.7" To "13.2" p. 584 Top line Change "10.8" To "13.3" p. 605 Line 18 Change "i++)" To "i++) {" p. 623 Line 5 from bottom Change "add" To "adding" p. 624 Add a new line 8 from the bottom "time1 = System.currentTimeMillis();" p. 625 Line 4 Change "4747" To "2447" p. 625 Line 13 Change "end" To "end of" p. 638 Line 3 from the bottom Change "hashValue" To "hashCode" p. 644 Line 16 Change "operation" To "operate" p. 658 Top line Remove the extra "Figure 15.3" label p. 719 Chapter 9, Answer 3 Change "50.00,3.5" To "1500.00, 0.35" p. 725 Chapter 3 Answer to 3.a Add ; to the end of first line code p. 725 Chapter 3, Answer 7 Change "e" To "c" p. 725 Replace line 4 from the bottom with String input =JOptionPane.showInputDialog("Enter an integer"); i = Integer.parseInt(input); p. 726 Change the answer to exercise 1, Chapter 7 to "Action, Item, Item, Action" p. 730 Change "BadComapre" To "BadCompare" p. 730 Change "CalculatePay.java 75" To "CalculatePay.java 71" p. 731 Change "FileReadAddresses.java 312" To "FileReadAddresses.java 512" p. 734 Change "pow 65" To "pow 165"