Errata


Print Print Icon

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



Version Location Description Submitted By
Printed Page xii
2nd paragraph

Extra "and" in "we provide compelling, realistic and examples and avoid merely
cataloging features."

Anonymous 
Printed Page xiv
1st paragraph

Something is missing or wrong in "embedding Java code in HTML support": do you mean
"support for embedding Java code in HTML"?

Anonymous 
Printed Page xv
3rd bullet point in "On the CD-ROM"

Ant isn't "a Java servlet engine". The text from the next bullet got copied into this
one.

Anonymous 
Printed Page 6
3rd paragraph

"Optimization" should be plural in "Also remember that these optimization can be made
at runtime".

Anonymous 
Printed Page 7
1st line

Should be "to" instead of "the" in "which tell it whether the emphasize quick start-
up time".

Anonymous 
Printed Page 11
3rd full paragraph

Should be "a" instead of "an" in "In an language such as C or C++".

Anonymous 
Printed Page 29
!st paragraph

The error is not in the text, but on the accompanying CD. For chapter 2 in the
exercises, the HelloJava.java example, the CD has several implmentations of the
Hello, Java program. The first 3 are supposed to be commented out using a "C style"
multiline comment. It should start with a "/*" and instead it starts with a "*/"
which causes numerous compiler errors. Reverse the order and it compiles fine with
javac version 1.4.

This is confusing since it is the first example in the book.

Anonymous 
Printed Page 29
4th alinea ("If we stopped here ...")

I stopped here.
The compiler complained about an unresolved symbol "JFrame" because the line "import
javax.swing.*;" was not yet included in the file.

Anonymous 
Printed Page 30
Figure 2-1

The titlebar shows "HelloJava1", when the accompanying program sets it to "Hello
Java!". Meanwhile (and now I'm being really picky!), the label shows "Hello, Java!"
while the program does not include the comma.

Anonymous 
Printed Page 34
2nd line

Should be: "declared IN our"

Anonymous 
Printed Page 34
HelloComponent code sample

If you enter the HelloComponent code in a seperate Java file (As the text mentions)
then it fails to compile unless you add the line "import javax.swing.*;" instead of
the "import.awt.*;" given in the text. Took me a while to work that out...

Anonymous 
Printed Page 34
After the first paragraph

Missing the keyword "static" in the definition of main() method:
public void main(String[] args) {
should be replaced by
public static void main(String[] args) {

Anonymous 
Printed Page 35
1st paragraph

Do not place the class HelloComponent its own file, only mention it is possible.
Remove the word public from the class declarations on page 35 and page 38. When the
class is declared in the same file public is not allowed.

Anonymous 
Printed Page 35
Instead of "frame.getContentPane().add( hello ); " it should be

"frame.getContentPane().add( new HelloComponent() );"

Correct code was on the accompanying CD. The book does not provide
enough information about using sample code from the CD or even installing
the software. Inaddition, up to now, I have found the sample code for
all the examples on one file. Since you have to find the relevant code
stated on the book from a file with multiple examples, this makes it more
complicated if you are new to Java.
Content from HelloJava.java
*/
public class HelloJava
{
public static void main( String[] args ) {
System.out.println("Hello, Java!");
}
}
public class HelloJava
{
public static void main( String[] args ) {
javax.swing.JFrame frame = new javax.swing.JFrame( "Hello, Java!" );
frame.setSize( 300, 300 );
frame.setVisible( true );
}
}

import javax.swing.*;
public class HelloJava
{
public static void main( String[] args ) {
JFrame frame = new JFrame( "HelloJava" );
JLabel label = new JLabel("Hello, Java!", JLabel.CENTER );
frame.getContentPane().add( label );
frame.setSize( 300, 300 );
frame.setVisible( true );
}
}
*/
import javax.swing.*;
public class HelloJava
{
public static void main( String[] args ) {
JFrame frame = new JFrame( "HelloJava" );
frame.getContentPane().add( new HelloComponent() );
frame.setSize( 300, 300 );
frame.setVisible( true );
}
}
class HelloComponent extends JComponent {
public void paintComponent( java.awt.Graphics g ) {
g.drawString( "Hello, Java!", 125, 95 );
}
}

Anonymous 
Printed Page 37
Figure 2-2

In Figure 2-2, the HelloJava2 class under the JComponent class should be replaced by
HelloComponet class.

Anonymous 
Printed Page 49
figure 2.5

Figure shows a JFrame with size (300,150) and a message with position (125,75)
approximately

Anonymous 
Printed Page 51
First paragraph

The words "JComponent" and "and" are sticked together. The first line
"The JButton class is also derived from JComponentand therefore..."
should be replaced with:
"The JButton class is also derived from JComponent and therefore..."

Anonymous 
Printed Page 51
1st paragraph

The last sentence of this paragraph reads "JButton and HelloJava3 are, in this
respect, equivalent types of things". It should say "HelloComponent3" instead of
"HelloJava3" as it is the HelloComponent3 class, rather then the HelloJava3 class,
that is derived from the JButton class.

Anonymous 
Printed Page 52
2nd paragraph

It should be "HelloComponent3" instead of "HelloJava3" in "the add() method that
HelloJava3 inherits from Container".

The same could be said for the all the other mentions of HelloJava3 in the 1st and
2nd paragraphs on this page. (Though I suppose you could also argue that "the
HelloJava3 container" is HelloComponent3, and that there is no error.)

Anonymous 
Printed Page 53
second paragraph (immediately after code snippet)

on line 5 of this paragraph, it reads 'You also shouldn't be surprised to see that we
added a line to the HelloJava3 constructor, ...and refers to the line:

theButton.addActionListner( this );

but this line was actually added to the HelloComponent3 constructor and not the
HelloJava3 constructor (which doesnt actually appear on the page)

Anonymous 
Printed Page 55
end of 2nd paragraph

Reference should be to chapter 4 instead of chapter 5.

Anonymous 
Printed Page 65
last paragraph

"It loads Java class files and interprets the compiled String." & "... the
interpreter also serves as a specialized compiler that turns Java String into native
machine instructions." In both sentences, "String" should be "byte code".

Anonymous 
Printed Page 73
2nd to last paragraph

Again "code" or "byte code" has been replaced by "String" in "...a compiled class
that contains Java virtual machine String."

Anonymous 
Printed Page 74
1st paragraph

If you really want the reader to follow these instructions, remove the "extends Bird"
and the "..." or the file won't compile.

Anonymous 
Printed Page 82
3rd paragraph

The text says "a variable declaration can contain only a @see tag". The table below
correctly indicates that @deprecated can also be included, and the unlisted @since
tag can also be used with variables.

Anonymous 
Printed Page 104
Last example on the page.

"Try" should be "try"

Anonymous 
Printed Page 105
last paragraph

The variable "bar" should be in monospaced font in "...if an error had occurred in
the try clause we wouldn't have reached the bar assignment."

Anonymous 
Printed Page 108
near top of page

The assert statement throw an java.lang.AssertionError if the assert condition is
false.

The code sample

assert foo != null : "foo is not null!"

should read

assert foo != null : "foo is null!";
OR
assert foo != null : "foo cannot be null!";

Anonymous 
Printed Page 112
Last code example before the footnote

The example shows an array of int being initialised within a brace set { ... }. It
gives 1 as the first prime. 1 is not a prime, the first prime is 2.

To simplify n is a prime if n = x * y only for (x,y) = (1,n) where x and y are two
distinct numbers, 1 and 1 is only one number.

Anonymous 
Printed Page 119
4th paragraph

Semicolon used instead of comma in "As you'll see in Chapter 6 when we talk about
subclassing; there's more to learn about how methods see variables."

And it should be "aspects" instead of "aspect" in "Both aspect differ from static
methods..."

Anonymous 
Printed Page 131
3rd paragraph

The variable "time" should be in the monospaced font in "Here we have implemented the
default constructor so that it sets the instance variable time by calling a
hypothetical method..."

Anonymous 
Printed Page 144
1st paragraph

The semi-colon is badly typeset in "That is why static methods are called
"static";they are always bound at compile time." I'm not sure if your style calls for
semi-colons to be inside the quotes, but in any case there should be a space in
there.

Anonymous 
Printed Page 148
2nd to last paragraph

There is an incorrect comma after "subclass" in "Even if we create an instance of a
subclass, our code has never seen before (perhaps a new object type loaded from the
network), any overriding methods that it contains are located and used at runtime,
replacing those that existed when we last compiled our code."

Anonymous 
Printed Page 154
2nd line

Should be "event" instead of "even" in "...in which listener objects register with
even sources."

Anonymous 
Printed Page 165
2nd to last line

The java.util.Iterator interface uses "hasNext()" not "hasMore()".

Anonymous 
Printed Page 167
top

if ( hasMoreElements() )

should be

if (hasMore() )

hasMore() was defined on page 166, and there is no other reference to
hasMoreElements()

Anonymous 
Printed Page 172
2nd paragraph

Missing space between "javap" and "utility" in "Now take a look at it with the SDK's
javaputility..."

Anonymous 
Printed Page 172
4th paragraph

Extra "a" before "such" in "when you're invoking a such a utility, you need to
specify these files explicitly or use a wildcard that finds them."

Anonymous 
Printed Page 179
1st code example

Since we are "Continuing with the previous example" the variable should be "myclass"
not "strClass" in

String s2 = (String)strClass.newInstance( );

Anonymous 
Printed Page 187
code example

There are a number of bugs in the example:

-- method invoke() in interface InvocationHandler must be public and return Object

-- the variable interfaceName is never declared (you could use
method.getDeclaringClass().getName())

-- the Class.forName() call must be enclosed in a try block to catch
ClassNotFoundException

-- the array passed to newProxyInstance() should consist of "clas", the interface
class, not "class"

Anonymous 
Printed Page 205
First sentence in first full paragraph

The method "waiterMethod()" is referred to as "waiter-Method()". There should be no
"-" in the name.

Anonymous 
Printed Page 237
Bottom of page

I would just like to note, when you say:

"In C++, where classes don't derive from a single Object class that supplies a base
type and common methods, the elements of a collection would usually be derived from
some common collectable class. This forces the use of multiple inheritance and
brings its associated problems."

That's untrue. Collections don't take only Collectable objects, they use templates.
Therefore, multiple inheritance isn't an issue when using collections in C++.
I know because I'm also a C++ programmer.

Anonymous 
Printed Page 243
2nd Full Paragraph, email example

"w+@w+(.w)+" should probably read "w+@w+(.w+)+"

as it is written in the book, the expression only works if any dotted elements after
the first are only one character (user@mail.c or user@mail.a.b.c but not
user@mail.com)

Anonymous 
Printed Page 244
Alternation section - "parsing dates" example

w+, w+ d+ d+|dd/dd/dd //pattern 1 or pattern 2

should be:

w+, w+ d+ d+|dd/dd/dddd // pattern 1 or pattern 2

The text after the example states "In this expression, the left side matches patterns
such as Fri, Oct 12 2001, and the right matches 10/12/2001." Pattern 2 (the right
side) needs four digits (d) to match the year "2001".

Anonymous 
Printed Page 250
First example

The description and example of the String.split() method is wrong.
It's not static and therefore it also has a different argument list.

In the example code, the regex is also wrong. There are single backslashes where
there should be double.

The text says you can control whether you get empty strings, using an optional limit
field. That's not true. The limit field only limits the number of matches.

Anonymous 
Printed Page 258
2nd paragraph, after three lines of code

The addElement() method should be changed to add() method to be consistent with the
previous block of code, and also because the List interface does not declare the
addElement() method.

Anonymous 
Printed Page 264
Section Collections and Arrays, after second paragraph

The line:
String[] myStrings = (String[]) myCollection(new String[0]);
should be changed to:
String[] myStrings = (String[]) myCollection.toArray(new String[0]);

Anonymous 
Printed Page 268
2nd paragraph

In the last paragraph, the following line:
"Vector's methods are synchronized by default, unlike the other Maps. The old
Hashtable has been updated...."

should be reformatted as:
"Vector's methods are synchronized by default. Unlike the other Map's
implementations, the old Hashtable has been updated...."

Anonymous 
Printed Page 274
Code example at the bottom of the page

for ( Enumeration e = props.propertyNames( ); e.hasMoreElements; ) {
String name = e.nextElement( );
...
}

should be:
for ( Enumeration e = props.propertyNames( ); e.hasMoreElements( ); ) {
String name = (String)e.nextElement( );
...
}
or
for ( Enumeration e = props.propertyNames( ); e.hasMoreElements( ); ) {
String name = e.nextElement( ).toString( );
...
}

Anonymous 
Printed Page 275
1st Paragraph, section Loading and Storing

In the section "Loading and Storing", immediately after the first paragraph, the code
line:

props.save(System.out, "Application Parameters");

should be changed to:

props.store(System.out, "Application Parameters");

because the save() method has been deprecated since SDK 1.2, and is efffectively
replaced by the store() method. As a result, any references to the save() method in
the next paragraph should be replaced by the store() method.

Anonymous 
Printed Page 275
System Properties, first 2 sentences

The java.lang.System class provides access to basic system environment
information through the static System.getProperty( ) method. This method
returns a Properties table that contains system properties.
should be:
The java.lang.System class provides access to basic system environment
information through the static System.getProperties( ) method. This method
returns a Properties table that contains system properties.
(System.getProperty( ) requires either one or two String arguments and
returns information regarding the specified arguments)

pg 307, Table 11-1: listfiles() should be listFiles()

Anonymous 
Printed Page 309
Example under 4th paragraph

Example has:
FileInputStream fooOut = new FileOutputStream( ...
FileInputStream pwdOut = new FileOutputStream( ...

Should be
FileOutputStream fooOut = new FileOutPutStream( ...

etc.

Anonymous 
Printed Page 321
Last paragraph

The first sentence of the paragraph said that:

"Buffer is a subclass of java.nio.Buffer object."

should be changed to reflect the nature of the java.nio.Buffer class. For example:

"The Buffer class in the java.nio package is the superclass for all buffer classes."

or something similar to.

Anonymous 
Printed Page 324
last paragraph

CharBuffer cbuf = CharByffer.allocate( 64*1024 );
should read
CharBuffer cbuf = CharBuffer.allocate( 64*1024 );

similarly
ByteBuffer bbuf = ByteByffer.allocateDirect( 64*1024 );
should read
ByteBuffer bbuf = ByteBuffer.allocateDirect( 64*1024 );

Anonymous 
Printed Page 341-388
Entire section from page 341-388

There is an entire section, from page 341 to 388, missing from the 3rd edition.
In place of these pages, pages 293 to 340 have been repeated.

I do not know of any further problems as I am currently reading through the book.

Is there any way someone could email me the missing pages ? or post online somewhere ?

Lee Bassom 
Printed Page 372
{12.5 ONLINE} LargerHttpd program

I am using the Safari on-line version of the book, so I do have the exact page
number.

The LargerHttpd.java program has two errors which show up on compilation.

1)

LargerHttpd.main() contains the following:

public static void main( String argv[] ) throws IOException {
new LargerHttpd( ).run( Integer.parseInt(argv[0]) );
}

The run method signature is run(int port, int threads). I fixed this by adding a
2nd arg with Interger.parseInt(argv[1])

2)

HttpdConnection.write() contains the following:
int got = file.transferTo( filePosition, remaining, clientSocket );

My compiler complains about a loss of precision because the return type of
file.transferTo is long. Changing to long got fixes the problem.

I found these with Sun's J2SDK 1.4.1-1 on Linux

Anonymous 
Printed Page 476
in program after second comment

Container c = f.getContentPane( );

should be

Container c = frame.getContentPane( );

Anonymous 
Printed Page 481
Middle of page

In orde to follow the example in the book, so the the menu items are vertical instead
of horizontal the following line

frame.setSize(200,50);

should be

frame.setSize(50,200);

Anonymous 
Printed Page 506
Figure 17-4

Screen dump is definitively not taken from "Canis Minor" application

Anonymous 
Printed Page 667
multiple locations on page

The "code" attribute of the APPLET tag should have a file name, not a class, as its
value (i.e., "AnalogClock.class" and not "AnalogClock"). As the examples stand,
appletviewer will not find the code to run (although some browsers may be more
forgiving).

Anonymous 
Printed Page 721
4th paragraph (CryptURLConnection code)

The first line of the CryptURLConnection.java example code needs to be...
package learningjava.protocolhandlers.crypt;
...The authors talk about including it in the URLStreamHandler.java file from the
page before, but then define it as a separate file. Without adding it to the package
the compiler can't find it. Even if you import the classes from the excersize, it
still really should be part of the crypt package. The author may want to comment on
this?

Anonymous 
Printed Page 724
First Paragraph

The version of setURL used in the Handler class is depreciated. The compiler for 1.4
spits out

Handler.java:13: warning:
setURL(java.net.URL,java.lang.String,java.lang.String,int,java.lang.String,java.lang.String)
in java.net.URLStreamHandler has been deprecated

java.sun.com...
Use setURL(URL, String, String, int, String, String, String, String)

Anonymous 
Printed Page 737
glossary

Swing package missing.
Also add javax.swing to text for API (?).

Anonymous