Errata

Learning Java

Errata for Learning Java

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 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 7
1st line

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

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
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 37
Figure 2-2

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

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 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 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 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 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 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 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 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 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 ?

Note from the Author or Editor:
I don't have a copy of the printed third edition (gave my last one away recently). I assume we would have noticed a major printing mistake by now?

Lee Bassom  Feb 10, 2009 
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