Errata 3rd Edition 

[ Home ]General Information ] Student Resources ] [ Site Map ]

Errata listed here are corrected in the 3rd Ed SDK 1.5 Update book. Information on this version of the 3rd Ed book can be found here.

Errata for the 3rd Ed SDK 1.5 Update book can be found here.


So far there are only minor errors to report. I would appreciate very much if you could email me with any errors not reported yet. I will acknowledge your help by listing your name here.

November 03, 2003 -- I added more corrections. I'm happy to report that the majority of these are still very minor errors.

January 07, 2004 -- More corrections added (still mostly minor errors).

Page

Description

21, 22, 23

(Fig 1.8, 1.10, 1.11)

Because I did not state any rules for coloring the diagrams in the book, these are, strictly speaking, not an error. However, the fact remains that these three figures do not include the color I intended to use. Here are the rules (doc in PDF) I submitted to the compositors. Rule No 7 is the one they should have followed, but didn't. Background color used for the object (instance) icons in Figures 1.8, 1.10, and 1.11 is wrong.

The correct color scheme is the one used in Figure 1.7. Here are the colors used in Fig 1.7 (not exactly the same colors, but as close as I can get to the actual ones used in the book):

 
 

The top color is the color I used for an instance (object) of a class. The bottom color is the color I used for a class. See the examples in Fig 1.3, 1.4, and 1.5. Let's call the top color OC (object color) and the bottom color CC (class color). When I draw a simple icon for an object, I use only OC for background. However, when I include the data members or methods of an object, I use OC in the top and CC in the bottom, as illustrated in Fig 1.7. Why? Because the data members and the methods of an object are defined in the class the object belongs. So it's logical to color this part in CC to indicate this relationship. I wanted the colors in the diagrams not only visually attractive, but semantically enriching.

61, 62, 66

The first parameter null is missing in the statements (one in page 61, two in page 62, and one in page 66) that call the showMessageDialog method.

Detected by one of Norm Cohen's students.

63

The assignment statement
      text1 = " "; //empty string
at the middle of the page should be
      text1 = ""; //empty string

72

The title of the Design Document table should be Monogram, not LoanCalculator.

Detected by John Kirkland.

82
(Exercise 22)

Replace the reference to MainWindow to JFrame. I'm not using MainWindow anymore in the third edition.

Detected by Norm Cohen (Morrisville State University, formely SUNY Morrisville).

161

The listing in the Public Methods comment box at the top of the page includes

//      void      setExchangeRate (            )

It should be

//      void      setExchangeRate (  double    )

Detected by Daniel Loeb (Brent International School, Manila).

165

The explanatory comment in blue at the bottom of the page states

The statement calls the
constructor that accepts
one int parameter

It should be

The statement calls the
constructor that accepts
one double parameter

Detected by Daniel Loeb (Brent International School, Manila).

195

The section heading now reads Passing an Object from a Method. Huh? Where was my copyeditor? I checked my original file and there it was... Passing...from. I don't know what happened. Maybe a copy-and-paste-and-forgot-to-change error. But no excuse. The correct heading, of course, should be Passing an Object to a Method.

Detected by Edwin Li (student - Hong Kong Institute of Vocational Education, Shatin).

201

The return statement at the bottom of the page now reads
      return Integer.parseInt(inputStr);

It
should be
      return Integer.parseInt(inStr);

The correct local variable is
inStr, not inputStr.

Detected by Edwin Li (student - Hong Kong Institute of Vocational Education, Shatin).

220

The statement for computing the monthly payment inside the getMonthlyPayment method is
       monthlyPayment = (loanAmount * monthlyInterestRate)
                         /
                        (1 - Math.pow(1/(1 + monthlyInterestRate),
                                           numberOfPayments ) );

It
should be
      monthlyPayment = (loanAmount * monthlyInterestRate)
                         /
                        (1 - Math.pow(1/(1 + monthlyInterestRate/100.0),
                                           numberOfPayments ));

You need to divide
monthlyInterestRate by 100.0 to convert a percentage point (e.g., 1.5) to a fractional value (e.g., 0.015). Sample program source code must also need to be corrected.

Detected by Jack Tompkins (University of North Carolina at Wilmington).

230
(Exercise 13)

The formula includes the expression age % 10. It should be age / 10 because the logic behind the formula is that you expect to be heavier as you get older. With age / 10, you'll get 1 kg for every decade. This formula is not exactly for real because your weight will not continue to grow as you get older. Health professionals use BMI (Body Mass Index) that computes healthy weight given a person's height. Age is not a factor in determining one's healthy weight.

234, 235, 236, 237, 238, 240

The first parameter null is missing in the statements that call the showMessageDialog method.

 

238

In the second sample if statement at the middle of the page, the color of the first left brace is blue. It should be red.

282

The color for the object icon labeled :MyHelperClass should be the same as the one for MyClass2, because MyHelperClass is the class we implement. (I actual do not like the colors used in this diagram because they are not consistent with my diagram coloring scheme. I wanted to use some form of shading, but wasn't able to convey my idea precisely to the compositors.)

298, 299

The return statement of the inputShapeType method is

return type;

The correct statement is

return selection;

324

The sample loop at the bottom of the page should be

count = 0;

while (count != 10) {
     ...
     count++;
}

Detected by Jasmine Tan (student - University of Melbourne, Australia).

325

This is really not an error, but included here for your information.

In the 'You Might Want to Know' box, I stated that the elevator moving from the ground floor to the fourth floor will take 1.5 seconds because there are three floors to rise. This is a correct description because in United States, and in many other countries, I presume, the ground floor is the first floor. In UK, however, the ground floor is the 0'th floor. So in UK, there are four floors to rise from the ground floor to the fourth floor. I will replace the word 'ground' to 'first' to avoid confusion in the next edition.

It is interesting to note that UK uses zero-based indexing for counting the floors.

Detected by Dharmesh Kumar Chavda (student - University of Leicester, UK).

334

Code samples for the showConfirmationDialog method include typo. The word Confirmation is mispelled twice as Confirmmation.

Detected by Edwin Li (student - Hong Kong Institute of Vocational Education, Shatin).

335

The sentence on the fourth line of the last paragraph now reads "In the sample code, the control variable i is first initialized to 0, ..." The correct sentence should be "In the sample code, the control variable i is first initialized to 1, ..." The variable i in the sample code is initialized to 1, not 0.

Detected by Edwin Li (student - Hong Kong Institute of Vocational Education, Shatin).

336

In Figure 6.7, the increment operation i++ is labelled as initialization. The operation, of course, must be labelled as increment.

Detected by Sean Maynard (University of Melbourne, Australia).

351

The statement to compute the random number is written as

int randomNumber = (int) (Math.floor(Math.random * (max - min + 1)) + min);

It should be

int randomNumber = (int) (Math.floor(Math.random() * (max - min + 1)) + min);

We need parenthese ( ) after Math.random.

Detected by Dharmesh Kumar Chavda (student - University of Leicester, UK).

417

Quick Check question 1 reads "For which object do we register as an action listener..." Change this sentence to "To which object can we register an action listener..."

537

The sample code

Pattern pattern = Pattern.compile(regex);
Matcher matcher = p.matcher(str);
matcher.matches();

should be

Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(str);
matcher.matches();

The correct name of a Pattern object is pattern, not p.

Detected by Sean Maynard (University of Melbourne, Australia).

573

The header comment for the source code listing at the bottom of the page should read

/*
    Chapter 10 Sample Program:
   
     Display the differences between the annual average and measured
         monthly rainfall amounts

    File: Ch10Rainfall.java
*/

This is definitely one of those copy-and-paste-and-forgot-to-change errors.

Detected by Norm Cohen (Morrisville State University, formely SUNY Morrisville).

625

The sample code at the top of the page refers to the capacity method. This method is defined for Vector, but not for List. Ignore the whole discussion about finding the capacity of a list. The capacity of the underlying data structure is an implementation detail so you really don't need to know such information. In other words, knowing the capacity of a list really won't do any good to the client programmers.

653

The root node in the heap at the bottom right side of the page should be 84, not 23.

Detected by Carl Doughty

659

The for loop inside the isValidHeap method is

for (int i = 0; i <= end/2; i++) {

It should be

for (int i = start; i <= end/2; i++) {

Detected by Stu Hansen (University of Wisconsin - Parkside)

660

The assert statement inside the maxChild method is

assert heap[leftChildIndex] <= end:

It should be

assert leftChildIndex <= end:

Detected by Stu Hansen (University of Wisconsin - Parkside)