Errata

Java In a Nutshell

Errata for Java In a Nutshell

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page 18
Third line from the bottom of the page

One of our reader suggests that nul = ' ' is not conform to the latest specification
of the language.

char a = 'u0000'; /* ok */

but

char a = ''; /* compile error! */

Anonymous   
Printed Page 20
First paragraph of "The Unicode Character Set"

The second to last sentence says: "The format is designed so that
plain ASCII and Latin-1 text are valid UTF-8 byte streams".

Plain ASCII is valid UTF-8 but Latin-1 is not. The top half of
Latin-1 uses the high order bit of each byte in a manner quite
contrary to UTF-8.

Latin-1 is the same as the first 256 positions in Unicode but when
Unicode text is represented as UTF-8 the encoding of characters
which are valid Latin-1 but beyond the basic ASCII set will be different from pure
Latin-1. In fact, the extra Latin-1
characters will be encoded as two bytes each in UTF-8.

An example from The Unicode Standard, Version 3.0, page 19:

The character LATIN CAPITAL LETTER A WITH RING ABOVE is represented
in the ISO-8859-1 (Latin-1) character set as 0xC5 and in Unicode
as U+00C5 (i.e., the same numerical value) but when this is encoded
as UTF-8 it is represented by the two byte sequence 0xC3 0x85.

Conversely, if a Latin-1 A ring character (i.e., a 0xC5 byte) was
encountered in a file being read as UTF-8 it would be
misinterpretted as the first byte of a two or more byte UTF-8
sequence.

Anonymous   
Printed Page 21
15th row from the bottom

The book reads "An identifier must begin with [...] or a Unicode currency
symbol[...]". If that is so, then the example of a legal identifier on row 6 from the
bottom is wrong. Because the character theta is not a currency symbol, or a letter,
or an underscore.

Anonymous   
Printed Page 40
paragraph 4

It reads 'If the left operand is a long, the right operand should be between 0 and
63. Otherwise the left operand is taken to be an int, and the right operand should be
between 0 and 31.'

This is wrong! The modulo 64 or modulo 32 value of the right operand is used. So if
an int is <<'d by 34, it really is <<d by 2.

Anonymous   
Printed Page 40
Unsigned right shift section

In the last example,
"-50 >>> 2 // 0xFFFFFFCE >>> 2 = 0x3FFFFF33 = 107371811"
is wrong, it should be,
"-50 >>> 2 // 0xFFFFFFCE >>> 2 = 0x3FFFFFF3 = 1073741811"

Anonymous   
Printed Page 43
First sentence in "Statements" section

"A statement is a single command executed b the Java interpreter"

Anonymous   
Printed Page 67 and 91

// Create a Point object representing (2, 3.5) and store it in variable p
Point p = new Point(2.0, 3.5);

And on page 91:

Circle c = new Circle(); // Create a new Circle object; store it in variable c

This is inaccurate. References to the objects are actually being stored, not the
objects themselves.

Perhaps this is an actual bug, or maybe this was written intentionally to simplify
things, but in either case IMHO it should be corrected, as it can confuse the reader

^^

Anonymous   
Printed Page 91
4th paragraph

Beginning of 4th paragraph starts like this.

To use an instance method from outside the class in which it is defined, we must
prepend a reference...blah, blah, blah

what is the meaning of the word prepend? English is not my mother tongue and prepend
is not in my English dictionary.

Anonymous   
Printed Page 93
2nd complete paragraph

The 3rd sentence "There are many cases in which is is..." should read "There are many
cases in which it is...".

Anonymous   
Printed Page 97
3rd paragraph - - I do not have the book with me and am not certain if this is

the actual paragraph;
The following sentence contains the error:
"If you disassemble the byte codes in a Java class file, you'll see the class
initialization code in a method named <clinit>."

"static" is the name of the method that contains the class initialization code. This
method is not called <clinit> as described on Page 97.

Anonymous   
Printed Page 101
last sentence on page

There is a stray "it". The last sentence "The ability...by subclassing, or
extending, it is central..." should read "The ability...by subclassing, or extending,
is central...".

Anonymous   
Printed Page 110
5th complete paragraph (just above Data Hiding and Encapsulation), last

sentence;
The sentence states that the super syntax may be used to invoke a shadowed class
method. It should be clarified that this syntax only valid in instance methods. The
only syntax available within static methods is using the parent class name.

Anonymous   
Printed Page 121
2nd paragraph

On the fourth line of paragraph two is a sentence beginning "If you use an abstract
clas..." An 's' was left out of the word "class".

Anonymous   
Printed Page 162
4th line

A Timer object named "timer" is instantiated on line 2. Two lines later, the schedule
method is called, except you've printed "Timer.schedule(...)" (which mistakenly
attempts to invoke an instance method on a class) instead of the correct
"timer.schedule(...)".

Anonymous   
Printed Page 162
4th line on the page

Timer.schedule(displayTime,0,1000);

should be lower case T:
timer.schedule(displayTime,0,1000);

Kenneth Rowe  Oct 13, 2009 
Printed Page 163
Sample code for Deadlock

The sample code states

t2.start(); // Locks resource2 and now neither thread can progress!

This is entirely dependent on the scheduling of threads. This sample
code can complete successfully (and probably will on a lot
of systems if this this the only code executed).

A note clarifying this would be helpful as a reader may enter the code
and be confused when a deadlock does not occur

Anonymous   
Printed Page 163
First paragraph under "Coordinating Threads with wait() and notify()" heading

The fifth sentence here states "When a thread calls the wait() method of an object
any locks the thread holds are temporarily released ...". This isn't correct (or at
least the use of "any locks" is misleading) - the thread ONLY releases the lock for
the object whose wait() method was invoked; any other objects' monitors held by that
thread will not be released. This is confirmed by the following link to the online
API documentation:

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html#wait(long)

Anonymous   
Printed Page 177
TextEditor example

Missing comma in code example:

dictionary = userprefs.get("dictionary"
^

Anonymous   
Printed Page 183
Near the top of the page

"The preceeding code relies on the fact that ISO-8895-1 is an 8-bit
encoding..."

Should say "ISO-8859-1", not "ISO-8895-1".

,

Anonymous   
Printed Page 186
unconnected socket example

s.setSOTimeout
^ wrong case, should be:
s.setSoTimeout

Anonymous   
Printed Page 198
first code chunk

The code used to describe how to apply a digital signature to a byte[] array uses a
String variable named "signer" to hold the name of the key's alias. This is
confusing, because when you use keytool to generate a key, you can specify the alias
(a unique name within that keyfile), as well as the name of the signer. In the
example code, signer contains a value of "david" and is passed to
keystore.getKey(...). This makes is seem to the reader that the first value passed
to getKey is the name of the person who signed the private key, rather than the alias
of that private key. (It took me a while to figure this out). I think this could be
easily clarified by naming the variable "alias" instead of "signer".

Anonymous   
Printed Page 247
3rd and 4th paragraph

In the VM options, the book says the default for -Xms is 1MB and for -Xmx is 16Mb.
According to the JDK docs (for both JDK 1.3.x and 1.4.x), these defaults are 2Mb and
64 Mb respectively.

Anonymous   
Printed Page 248
1st paragraph, line 6

When a thread calls the wait() method of an object, any locks the thread holds are temporarily released, and...

should be:

When a thread t calls the wait() method of an object o, any locks of t that are associated with object o are temporarily released, and...

Albert Noll  Oct 27, 2010 
Printed Page 379
First paragraph, first sentence of Byte description

For consistency with the other primitive wrapper classes, the word 'immutable' should
be inserted as follows:
397 currently eads, "This class provides an object wrapper..." but should read, "This
class provides an immutable object wrapper...". If the class is mutable, explain why
it differs from the other 7 primitive wrappers. Currently it is misleading and can
seem slightly reliable since this is the most fundamental data type to a computer
(through some ill-conceived discontinuous matter of rational).

Anonymous   
Printed Page 413
First paragraph, first sentence of Short description

For consistency with the other primitive wrapper classes, the word 'immutable' should
be inserted as follows:
413 currently eads, "This class provides an object wrapper..." but should read, "This
class provides an immutable object wrapper...". If the class is mutable, explain why
it differs from the other 7 primitive wrappers.

Anonymous   
Printed Page 648
5th line - setTimeInMillis(long millis)

"public void setTimeInMillis (long millis)"
should be "protected" sted "public".

Anonymous   
Printed Page 855
3rd paragraph

"If that method [getCharacterStream] returns false..." can't be right.
getCharacterStream returns a pointer. According to the SAX documentation null is
used to indicate that there isn't a character stream available.

Anonymous