Errata

Please check here often as we will update the errata regularly.

Errata updates:

Date of updatePrintingPages
2004-01-091st10, 14, 24, 25, 27, 39, 64, 83, 95, 98, 101, 102, 103, 108, 117, 126, 139, 140, 141, 142, 155, 182, 185, 187, 190, 193, 199, 201, 205, 211, 214, 235, 254, 261, 272, 371, 471, 522, 525, 526, 529, 569
2004-03-031st, 2nd20, 56, 82, 271, 279, 322, 469, 532, 544, 572, 577, 609, 613
2004-04-251st, 2nd18, 70, 76, 159, 171, 201, 203, 213, 284, 285, 297, 303, 305, 306, 324, 404, 431, 450, 472, 598
2004-11-18 (1) 1st, 2nd 62, 103, 140, 249, 279, 287, 381, 413, 431, 484, 522, 532, 540
2004-11-18 (2) 2nd 214, 218
2005-09-05 1st, 2nd 140, 165, 307, 370, 394, 434, 479

Acknowledgements:

Many thanks to the following readers for their diligent observations: Einar Andresen, Brian Bradshaw, Nicola Cammillini, Nicola Cammillini, Juan Carlos Castro, David Featherstone, John Holcroft, Leong Jern-Kuan, Rajesh Kesarwani, Ken Kisser, Tony LaPaso, Luba Leyzerenok, Adam Lorentzon, Philip Mitchell, Sigmund Nysæter, Pat Owens, Raul Saavedra, Oliver Schoettler, Oliver Schoettler, Mark Sullivan, Frederik Uyttersprot, Jennie Yip.

Errata list:

The errors listed below are ordered according to their page numbers. Each error is labeled with all the printings where the error occurred. E.g. "1st printing" indicates that the error occurred in the first printing, but has been corrected before the second printing, i.e. you won't find this error in the second printing.

Page 10

1st printing, Table 1.1, row "Instance Variable", remove stray ")":

CHANGE:

that is, when an object) of the

TO:

that is, when an object of the

Page 14

1st printing, RQ 1.5:

CHANGE:

about an instance method?

TO:

about an instance member?

Page 18

1st, 2nd printing, Programming Exercise:

DELETE WHOLE PROGRAMMING EXERCISE SECTION.

Page 20

1st, 2nd printing, Identifiers:

CHANGE:

cannot not be

TO:

cannot be

Page 24

1st printing, Table 2.6, 1st column, last three rows:

The character in each row should surrounded by single, straight apostrophies, not a right single qoutation mark.

Page 25

1st printing, add missing ("):

CHANGE:

        "Here comes a tab.\t And here comes another one\u0009!

TO:

        "Here comes a tab.\t And here comes another one\u0009!"

Page 27

1st printing, RQ 2.1, remove option (f):

DELETE WHOLE LINE:

(f) total#

Page 39

1st printing, Chapter Summary:

CHANGE:

integral, floating-point and Boolean.

TO:

integral, floating-point and boolean.

Page 56

1st, 2nd printing, Remainder Operator: %:

CHANGE:

attempting integer remainder operation with zero.

TO:

if the divisor evaluates to zero.

Page 62

1st, 2nd printing, 3.6, first bullet:

CHANGE:

For a operand of

TO:

For an operand of

1st, 2nd printing, 3.6, middle of page:

CHANGE:

This conversion is corresponds to

TO:

This conversion corresponds to

Page 64

1st printing:

CHANGE:

        // (1) Prefix order: increment operand before use.

TO:

        // (1) Prefix order: increment/decrement operand before use.

1st printing:

CHANGE:

        // (2) Postfix order: increment operand after use.

TO:

        // (2) Postfix order: increment/decrement operand after use.

Page 70

1st, 2nd printing, 3.11, above Table 3.9:

DELETE:

In the table, the operators are ranked, with the operator having the highest precedence first.

Page 76

1st, 2nd printing, 3.13, above Table 3.14:

DELETE:

The operators are listed in decreasing precedence order.

1st, 2nd printing, 3.13, above Table 3.14:

Page 82

1st, 2nd printing, The-right-with-sign-fill Operator >>:

DELETE:

This is the same as (-4 % 32).

Page 83

1st printing, 3.15:

Include "ternary conditional operator" as an index term pointing to the start of section 3.15.

Page 95

1st printing:

Include "program arguments" as an index term.

1st printing:

CHANGE:

        java Colors red green blue

TO:

        >java Colors red green blue

Page 98

1st printing, RQ 3.2:

CHANGE:

Create two method that both takes an

TO:

Create two methods that both take an

Page 101

1st printing, last code block:

CHANGE:

        Object objArray =

TO:

        Object[] objArray =

Page 102

1st printing, near top of page:

CHANGE:

for example, medium Pizzas.length has the

TO:

for example, mediumPizzas.length has the

Page 103

1st printing:

CHANGE:

the array size, that is, (<array name>.length-1).

TO:

the array size, that is, <array name>.length-1.

1st printing:

CHANGE:

by calling the method randomize() at (5).

TO:

by calling the method randomize() declared at (5).

1st printing:

CHANGE:

the method findMinimum() at (6),

TO:

the method findMinimum() declared at (6),

1st, 2nd printing, 1.4, Using an array, mid-page:

CHANGE:

(new Toppings[3])

TO:

(new Topping[3])

Page 108

1st printing:

CHANGE:

traverses the rows (mXnArray[i], 0

TO:

traverses the rows (mXnArray[i], where 0

1st printing:

CHANGE:

in each row in turn (mXnArray[i][j], 0

TO:

in each row in turn (mXnArray[i][j], where 0

Page 117

1st printing, 4.4:

CHANGE:

and hence cannot specify a return type,

TO:

and hence do not specify a return type,

Page 126

1st printing:

CHANGE:

name of packages on the underlying (hierarchical) file system.

TO:

name of packages to the underlying (hierarchical) file system.

Page 139

1st printing:

CHANGE:

and the method superclassMethodA at (2) and (3) respectively

TO:

and the method superclassMethodA() at (2) and (3) respectively

1st printing:

CHANGE:

and the method superclass MethodA have public accessibility,

TO:

and the method superclassMethodA() have public accessibility,

Page 140

1st printing, subsection "protected Members":

CHANGE:

and the method superclass MethodA have

TO:

and the method superclassMethodA() have

1st, 2nd printing, last code block:

CHANGE:

        SubclassB objRefB = new SubclassB();            // (1)

        void subclassMethodB(SuperclassA objRefA) {

TO:

        SuperclassA objRefA = new SuperclassA();        // (1)
        
        void subclassMethodB(SubclassB objRefB) {

1st, 2nd printing, last paragraph:

CHANGE:

The class SubclassB defines a field of type SubclassB (objRefB). The method subclassMethodB() has a formal parameter objRefA of type SuperclassA.

TO:

The class SubclassB defines a field of type SuperclassA (objRefA). The method subclassMethodB() has a formal parameter objRefB of type SubclassB.

2nd printing, last paragraph:

1st, 2nd printing, 4.9, SubclassB.java code:

Note: Instantiating SubclassB will cause a StackOverflowError because (1) tries to recursively create another SubclassB object.

Page 141

1st printing, subsection "Default Accessibility for Members":

CHANGE:

and the method superclass MethodA are defined

TO:

and the method superclassMethodA() are defined

Page 142

1st printing, subsection "private Members":

CHANGE:

and the method superclass MethodA have private

TO:

and the method superclassMethodA() have private

Page 155

1st printing:

CHANGE:

resides in a package called com.megabankcorp. records.

TO:

resides in a package called com.megabankcorp.records.

1st printing:

CHANGE:

should reside in a package called com.megabankcorp. system.

TO:

should reside in a package called com.megabankcorp.system.

Page 159

1st, 2nd printing, 5.2, after code examples:

CHANGE:

if more that one statement

TO:

if more than one statement

Page 165

1st, 2nd printing, 5.2, first line:

CHANGE:

must have a case label, or

TO:

must have a case or default label, or

Page 171

1st, 2nd printing, 5.4, Labeled Statements:

CHANGE:

it always immediately proceeds the statement

TO:

it always immediately precedes the statement

Page 182

1st printing, Example 5.9:

CHANGE LINE:

        printAverage(100,0);                                  // (1)

TO:

        printAverage(100, 20);                                // (1)

Page 185

1st printing:

CHANGE:

methods to query an exeception:

TO:

methods to query an exception:

Page 187

1st printing:

CHANGE:

programming errors (examplified by the

TO:

programming errors (exemplified by the

Page 190

1st printing, Example 5.10:

CHANGE:

        printAverage(100, 0);                                 // (1)

TO:

        printAverage(100, 20);                                // (1)

Page 193

1st printing:

CHANGE:

the statment at (9)

TO:

the statement at (9)

1st printing:

CHANGE:

the statment at (13)

TO:

the statement at (13)

Page 199

1st printing, 5.8:

CHANGE:

This ensure that a

TO:

This ensures that a

Page 201

1st printing:

CHANGE:

the compiler does not check them.

TO:

the compiler does not verify them.

1st, 2nd printing, 5.9, top of page:

CHANGE:

in the method protoype.

TO:

in the method prototype.

Page 203

1st, 2nd printing, 5.9, top of page:

CHANGE:

in the method protoype can be a

TO:

in the method prototype can be a

Page 205

1st printing, RQ 5.18:

CHANGE:

If an exception is uncaught in a method

TO:

If an exception is not caught in a method

Page 211

1st printing, last code block:

CHANGE:

        >javac -speed 1.3

TO:

        >javac -source 1.3

Page 213

1st, 2nd printing, 5.10, Assertion Execution for All Non-system Classes:

CHANGE:

the program with the options enabled, we get

TO:

the program with assertions enabled, we get

Page 214

1st printing, subsection "Assertion execution at the class level":

CHANGE:

enable assertions in the named class

TO:

enable assertions in the specified class

2nd printing, 5.10, text at bottom of page lost in 2nd printing:

INSERT:

It is worth noting that inheritance (see Section 6.1, p. 226) has no affect on the execution of assertions. Assertions are enabled or disabled on per-class basis. Whether

Page 218

2nd printing, after first code block:

DELETE:

Section 9.4 (p. 359) provides an example of a lock-status precondition in a non-synchronized method, where an assertion is used to check whether the current thread holds a lock on a certain object.

1st, 2nd printing, after first code block:

Page 235

1st printing:

CHANGE:

method in a sublass cannot

TO:

method in a subclass cannot

Page 249

1st, 2nd printing, RQ 6.9:

CHANGE:

added to MySubclass without causing

TO:

added to MySub without causing

Page 254

1st printing:

CHANGE:

with a dotted inheritance arrow.

TO:

with an unbroken inheritance arrow.

Page 261

1st printing, fix spacing before "new int[10];" on last line:

CHANGE:

        ISafeStack[]    iSafeStackArray = new ISafeStack[5];
        int[]           intArray        =  new int[10];

TO:

        ISafeStack[]    iSafeStackArray = new ISafeStack[5];
        int[]           intArray        = new int[10];

Page 271

1st, 2nd printing, RQ 6.23:

CHANGE:

is true when an

TO:

is true only when an

1st, 2nd printing, RQ 6.23:

CHANGE:

is true when an

TO:

is true only when an

Page 272

1st printing:

CHANGE:

during runtime, cannot always

TO:

during runtime cannot always

Page 279

1st, 2nd printing, RQ 6.28, (b):

CHANGE:

The use of aggregation is justified, since Planet has-a Star.

TO:

The code defines a Planet has-a Star relationship.

1st, 2nd printing, RQ 6.27, (b):

CHANGE:

The use of inheritance is justified, since Planet is-a Star.

TO:

The code defines a Planet has-a Star relationship.

Page 284

1st, 2nd printing, 7.1, last paragraph on page:

CHANGE:

classes is shown Example 7.1

TO:

classes is shown in Example 7.1

Page 285

1st, 2nd printing, Example 7.1, Overview of nested Classes and Interfaces:

CHANGE:

        // (7)  Annonymous

TO:

        // (7)  Anonymous

CHANGE:

        // (8)  Annonymous

TO:

        // (8)  Anonymous

Page 287

1st, 2nd printing, 7.2, first paragraph:

CHANGE:

Since static member classes and interfaces are members of an enclosing class or interface, they can have any member accessibility.

TO:

The accessibility modifiers allowed for members in an enclosing class or interface can naturally be used for nested class and interface members.

Page 297

1st, 2nd printing, 7.3, first paragraph:

CHANGE:

instance of TLClassA (denoted by a)

TO:

instance of TLClass (denoted by a)

Page 303

1st, 2nd printing, Example 7.9, in class StaticLocal:

CHANGE:

        double f6b = super.nsf1;   // (16a) Inherited from superclass.

TO:

        double f6b = super.nsf1;   // (16b) Inherited from superclass. 

Page 305

1st, 2nd printing, end of first paragraph:

CHANGE:

field nsf1 cannot be accessed, as shown at (18).

TO:

field nsf1 cannot be accessed, as shown at (17).

Page 306

1st, 2nd printing, Output from the program, (Java 1.5 beta):

CHANGE:

        class Painter$1$Circle
        class Painter$1$Map

TO:

        class Painter+1Circle
        class Painter+1Map

Page 307

1st, 2nd printing, 7.4, last paragraph:

CHANGE:

later to check the postconditon.

TO:

later to check the postcondition.

Page 322

1st, 2nd printing, Facilitating Garbage Collection, last paragraph:

CHANGE:

defines a method createList() at (7).

TO:

defines a method createList() at (8).

Page 324

1st, 2nd printing, 8.1, 3rd paragraph:

CHANGE:

shows that HeavyItems with identities Four and Five were never garbage collected, they are not accessible once they become eligible for garbage collection at (19) and (20), respectively.

TO:

shows that HeavyItem with identity Four was never garbage collected, it is not accessible once it becomes eligible for garbage collection at (20).

Page 370

1st, 2nd printing, 9.5, above last section:

DELETE:

There are several overloaded versions of the sleep() method in the Thread class.

Page 371

1st printing, Figure 9.6:

Add the following text to the bottom of the figure: objRef1 and objRef2 are aliases Format "objRef1" and "objRef2" in code font.

Page 381

1st, 2nd printing, Example 9.6, second line:

CHANGE:

private Thread theThread;

TO:

private volatile Thread theThread;

Page 394

1st, 2nd printing, 10.3, Converting Strings to Wrapper Objects:

CHANGE:

passed as argument (see (6a) in Figure 10.2).

TO:

passed as argument (see (6b) in Figure 10.2).

Page 404

1st, 2nd printing, Trigonometry Functions, last function:

CHANGE:

The method toRadians() converts an angle in radians

TO:

The method toDegrees() converts an angle in radians

Page 413

1st, 2nd printing, Example of case in strings:

CHANGE:

strA.toUppperCase();

TO:

strA.toUpperCase();

Page 431

1st, 2nd printing, Table 11.2, row 3 (TreeSet), column 5 (methods called):

DELETE:

equals()

1st, 2nd printing, Figure 11.3, rightmost box:

CHANGE:

HashTable

TO:

Hashtable

Page 434

1st, 2nd printing, 11.2, above last paragraph:

CHANGE:

Object remove()

TO:

void remove()

Page 450

1st, 2nd printing, 2nd paragraph:

CHANGE:

These classes also create a new empty map with an initial capacity and/or load factor.

TO:

Additional constructors create empty maps with given initial capacities and load factors.

Page 469

1st, 2nd printing, Field comparisons:

CHANGE:

the objects denotes by the references

TO:

the objects denoted by the references

Page 471

1st printing:

CHANGE:

The key represents the identify the item.

TO:

The key represents the identity of the item.

Page 472

1st, 2nd printing, near bottom of page:

CHANGE:

search key (9.1.1) is in the map

TO:

search key (9.1.1) in the map

Page 479

1st, 2nd printing, 11.7, end of first paragraph:

CHANGE:

Both these checks are embodied in the cast at (8) in Example 11.13.

TO:

Bad arguments will cause either the cast at (8) or the reference usage at (9) in Example 11.13 to throw the appropriate exception.

Page 484

1st, 2nd printing, bottom of page:

CHANGE:

boolean replaceAll(

TO:

static boolean replaceAll(

Page 522

1st printing, RQ 4.24:

CHANGE:

of the class (or for that matter, by other clients).

TO:

of the class (and for that matter, by other clients).

1st, 2nd printing, RQ 4.26:

CHANGE:

are only valid for methods.

TO:

are valid for methods but not for fields.

Page 525

1st printing, RQ 5.19:

CHANGE:

reached, since the runtimeException remains uncaught

TO:

reached, since the RuntimeException remains uncaught

Page 526

1st printing, RQ 5.20:

CHANGE:

The code printing 3 is never reached.

TO:

The code to print 3 is never reached.

Page 529

1st printing, RQ 6.11:

CHANGE:

of B by giving "Test"

TO:

of B by passing "Test"

Page 532

1st, 2nd printing, RQ 6.28:

DELETE:

The use of aggregation in this code is justifiable.

1st, 2nd printing, RQ 6.27:

CHANGE:

is not justifiable since, conceptually, a planet is-not-a star.

TO:

does not define a Planet has-a Star relationship.

Page 540

1st, 2nd printing, RQ 10.10:

CHANGE:

return the int value 11.

TO:

return the integer value 11.

Page 544

1st, 2nd printing, RQ 11.4:

CHANGE:

since the equal() method must be reflexive

TO:

since the equals() method must be reflexive

Page 569

1st printing, Q19:

CHANGE:

from the String and StringBuffer classes

TO:

from the String or StringBuffer classes

1st printing, Q20:

CHANGE:

will cause a runtime exception?

TO:

will raise a runtime exception?

Page 572

1st, 2nd printing, Q29:

CHANGE:

Select the three correct answers.

TO:

Select the two correct answers.

Page 577

1st, 2nd printing, Q40:

CHANGE:

Select the three correct answers.

TO:

Select the two correct answers.

Page 598

1st, 2nd printing, Table G.2, row 4 (Decimal Value 41), Column 3, (Octal Value):

CHANGE:

0123

TO:

051

Page 609

1st, 2nd printing, F, fields:

DELETE:

see member variables

Page 613

1st, 2nd printing, M, members, after terminology:

INSERT:

variables see fields

Khalid A. Mughal   •   Rolf W. Rasmussen