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 xvi
3rd p

link "http://rendezvous.com/java" does not exist

Anonymous   
Printed Page 1
anywhere

no license number or key given for JBuilder

*** Note *** Serial number and Activation key are obtained
by going to Borland's site and filling out their forms. The
URL is - http://www.inprise.com/jbuilder/foundation/download/

The book refers to download code from your site - WHERE?

*** Note *** example code can be found at the book's web page -
http://www.oreilly.com/catalog/9781565927186/

(Sample Chapter) The combo box example has the Italian word for ten as
"deici" instead of "dieci."

Anonymous   
Printed Page 22
2nd paragraph

(Error in -> Chapter 1: Yet another language?)

The paragraph finishes a discussion about application and user-level
security in Java by giving a general explanation about the use of digital
signatures and certificates. It states that the details of this topics will
be covered in Chapter 3 (Tools of the trade). This is incorrect because it
is until Chapter 20 (Applets) that the digital signatures and certificates
are adressed in full.

Anonymous   
Printed Page 31
In the examples HelloJava1 - 4

To me it seems quite interesting that the constructor for the class
HelloJavaX() is called within the class itself.

public class HelloJava1 extends javax.swing.JComponent {
public static void main(String[] args) {
...new HelloJava1( ));
...
}
...
}

This isn't explicitly mentioned and I wonder if the examples
wouldn't be easier to understand if the ideas were seperated in different
classes:

//file: Main1.java
public class Main1
{
public static void main(String[] args) {
javax.swing.JFrame f = new javax.swing.JFrame("HelloJava1");
f.setSize(300, 300);
f.getContentPane().add(new HelloJava1());
f.setVisible(true);
}
}

class HelloJava1 extends javax.swing.JComponent
{
public void paintComponent(java.awt.Graphics g)
{
g.drawString("Hello, Java!", 125, 95);
}
}

Also of interest: When I compile the examples HelloJava2 - 4
(with jdk1.2.2 under Linux) besides from the expected results
HelloJavaX.class I get classes HelloJavaX$1.class. I have no idea
why, and this is not mentioned in the chapter.

Anonymous   
Printed Page 59
paintComponent method

When running HelloJava4 under OS X, the paintComponent method has an odd side effect.
Since the default window on OS X is actually stripped, drawing theMessage with the
color set to the background color actually leaves a white outline of the text against
the stripes.

I was able to resolve this by changing the code from

public void paintComponent(Graphics g) {
g.setColor(blinkState ? getBackground() : currentColor());
g.drawString(theMessage, messageX, messageY);
}

to

public void paintComponent(Graphics g) {
if(blinkState)
g.drawString(theMessage, messageX, messageY);
}

Anonymous   
Printed Page 73
3rd paragraph (sample command)

No matter how I format my command and policy files, I can't get the
example command to work though my "EvilEmpire" class connection to a
local system via port 21 (ftp). The same class without the security
manager args works just fine however. Suggestions?

Sample policy file (latest attempt, called EvilEmpire.policy and
found in same path as given below):

/* AUTOMATICALLY GENERATED ON Tue Feb 06 10:20:59 CST 2001*/
/* DO NOT EDIT */

grant codeBase "file://home/tim/netbeans/Development/examples/ch03/" {
permission java.net.SocketPermission "192.168.3.2", "connect";
};

Anonymous   
Printed Page 82
In the last paragraph it says that

"Java source code can be written using the Unicode character set encoding
and stored either in its full 16-bit form or with ASCII-encoded Unicode
character values"

"...the first 256 characters are defined to be identical to the first 256
characters in the ISO8859-1 (Latin-1) encoding..."

I think this may be true of UTF-8, but not of Unicode. JDK 1.3 javac is
horribly confused by source code stored in Unicode format.

(Chapter 4)I would like to see more code examples in chapters 4-7.
These are important concepts for learning Java and I need programming
examples to run and play with to help me understand the concept.

Anonymous   
Printed Page 83
Last paragraph

In the May 2000 printing edition, the erroneous line reads:

"A doc comment is designed to be extracted by automated documentation generators, such as the DSK's javadoc program."

That should be SDK's not DSK's, i.e.:

"A doc comment is designed to be extracted by automated documentation generators, such as the SDK's javadoc program."

Anonymous   
Printed Page 85
The datatypes in table 4.2 should start with a lower case character

and not upper case.

This detail is important because changing the case for datatype means
different things in java.

Anonymous   
Printed Page 94
A not on unreachable statements

javac under JDK 1.3 or 1.2.2 does not complain about unreachable statements
(not by default, anyway). In fact, I'm sure I saw this mentioned somewhere
as a recommended technique for conditional compilation, in lieu of #ifdefs.

Anonymous   
Printed Page 95
In Table 4-3, the decrement operator is at the very top of the

table as: -

while it should be: --

Anonymous   
Printed Page 141
In the last paragraph, last sentence

"Even if we create an instance of a subclass, our code has never seen..."

The comma after subclass should not be there.

Therefore it should be something like:
"Even if we create an instance of a subclass our code has never seen..."

Anonymous   
Printed Page 144
last sentence, 1st paragraph

shouldn't "...toward the most specific overloaded method..." really be
"...toward the most specific overloaded or overridden method..."?

P.S. The following errata for page 153 is incorrect. The code is correct as
printed. It does not create an "instance" of an interface (TextUpdateable),
rather a reference (receiver) to the interface. This reference is later
populated with an interface. See text on page 152 just before code snippet.

Anonymous   
Printed Page 166
Code snippet in 'Inner Classes Within Methods'

'Class' should be 'class' (not capitalized), twice.

Anonymous   
Printed Page 167
Third code snippet: "Import" should be "import"

Anonymous   
Printed Page 173
Below the code snippet where is says "Using equals() is not the same as:"

See where it says "Using equals() is not the same as: if (userName == suspectName )
//Wrong".

The example in the book is misleading. Actually Object.java implements equals() as:
public boolean equals(Object obj) {
return (this == obj);
}
which therefore in the default case means equals() behaves as ==.

Anonymous   
Printed Page 183
1st and 2nd code example

Both code examples use "Class" rather than "class".

Anonymous  Aug 27, 2008 
Printed Page 199
2nd paragraph, 2nd sentence

"... to have the existing thread begin again., rather ..."

Remove the period before the comma.

Anonymous   
Printed Page 221
3rd line of text, from the top

Text refers to:

"...just like the C routine string():"

The correct name of the routine is "strcmp" so the sentence should read:

"...just like the C routine strcmp():"

Anonymous   
Printed Page 228
Title of section "The java.math Class"

The title should probably be "The java.math Package", since the section describes classes contained in that package.

Anonymous   
Printed Page 230
last paragraph, first line

The line as printed reads "You also need a wraper..."

The word "wrapper" should have an extra 'p' in it.

Anonymous   
Printed Page 239
description of List interface methods (5th paragraph)

Incorrect return type for remove, get, set methods:

Book has:
public void remove(int index)
...
public void get(int index)
...
public void set(int index, Object element)
...

Should be (per Java 2 Platform SE v1.3 API documentation)
public Object remove(int index)
...
public Object get(int index)
...
public Object set(int index, Object element)
...

Anonymous   
Printed Page 247
In the last code excerpt

e.hasMoreElements

should be:

e.hasMoreElements()

Anonymous   
Printed Page 247
At the bottom, inside the for loop

In the line :
String name = e.nextElement();

Function e.nextElement() returns an Object object. Type of the returned value should
be changed to String.
String name = (String) e.nextElement();

Anonymous   
Printed Page 248
1st sentence of "System Properies" section

The sentence "The java.lang.System class provides access to basic system
environment information through the static System.getProperty() method."
should say that System.getProperties() is the method to do this. The
following sentence states that getProperty() returns a Properties table,
but it is getProperties() that does this.

Anonymous   
Printed Page 248
"Loading and Sorting"

It is mentioned that the properties can be saved to a file by using a
FileOutputStream as the first argument to save(). However, save() seems to
be a deprecated mentod and the book fails to mention this.

"PropTest.java:25: Note: The method void save(java.io.OutputStream,
java.lang.String) in class java.util.Properties has been deprecated.
props.save(out, "Application Parameters");"

Anonymous   
Printed Page 254
second to last paragraph

Paragraph states that the ISO standard for country codes is ISO639, and for
languages is ISO3166. This is backwards: ISO639 is the set of codes for
languages, and ISO3166 is the set of codes for countries.

Anonymous   
Printed Page 257
2nd code snippet

The formatting example for percentages will only print 44% if the value of progress is 0.44. Change the declaration of progress to:
double progress = 0.44;

Anonymous   
Printed Page 275
The fourth paragraph reads:

'run()' is the only 'InputStream' method that 'FilterInputStream'
overrides.

It should read:

'read()' is the only 'InputStream' method that
'FilterInputStream' overrides.

Anonymous   
Printed Page 320
2nd

I don't know if the page is right, because I have a pdf version of the book

13.2 Containers.
You wrote : Three of the most useful container types... . JFrame is derived from
JWindow, which is pretty...

13.2.7 Windows and Frames
You wrote : Windows and Frames are the top-level... . JFrame, on the other hand, is a
subclass of JWindow that has a border...

JFrame IS NOT a subclass of JWindow.

Object -> Component -> Container -> Window -> Frame -> JFrame
Object -> Component -> Container -> Window -> JWindow

Anonymous   
Printed Page 344
In the example

// read results...
if ( urlcon.getResponseCode() != HttpURLConnection.HTTP_OK )
System.out.println("Posted ok!");
else {
System.out.println("Bad post...");
return;
}

... it should either have the != changed to == or the cases reversed since
this if provides the reverse functionality of what you were going for.

Anonymous   
Printed Page 364
last 3rd paragraph,

'...function in Java But they'
missing a period.

Anonymous   
Printed Page 371
3rd line, last sentence

"The name is returned by toString()."

The name that you set with setName() is actually returned by getName().

Therefore the sentence should read:
"The name is returned by getName()."

(Note: toString() will return a bunch of pieces of information of which
one of the things is the name set by setName(). However, getName() should
definitely be used if you want to get the name that you set in setName().)

Anonymous   
Printed Page 390
just after 2nd paragraph In Actual Code for vegomaticAdapter1

IN the third line of code, the word vegomatic is spelled wrong.
It is spelled Vegotmatic.

Anonymous   
Printed Page 391
3rd paragraph

In the last line in the 3rd paragraph on page 391 in the May 2000 first
edition of Learning Java, "...an event source It'sand its listener" should
read "...an event source and its listener".

Anonymous   
Printed Page 428
2nd paragraph, 2nd line

The first sentence ends with a method, the second begins with one. The
period between them is formatted as if it is all one expression:

savefile().loadfile() creates ....

instead of:

savefile(). loadfile() creates ....

Anonymous   
Printed Page 454
method "private float element()"

The example throws a compile-time error: "value may be used uninialized"

This is because the branch of the second if statement does not assign
anthing to this member. if one moves the line "value =
Float.valueOf(svalue).floatValue(); outside the scope of the second 'if'
statement, then the program works correctly, and will compile.

Anonymous   
Printed Page 516
last line

drawImage should be g.drawImage

Anonymous   
Printed Page 588
Second paragraph, next to last line

"container environment It also..."

Should read:

"container environment. It also..."

Anonymous   
Printed Page 595
Sixth paragraph, first line

"... expects to be embedded in GUI"

should read

"... expects to be embedded in a GUI"

Anonymous   
Printed Page 605
Second code snippet, lines 4 and 5

The applet width and height specifications are reversed:

"width = pixels_high"

Should read:

"width = pixels_wide"

"height = pixels_wide"

Should read:

"height = pixels_high"

Anonymous   
Printed Page 617
Certificate example

Note that the example certificate expired in January 2000, rendering this example unusable. If nothing else, the downloadable sample code and certificate should be updated.

Anonymous   
Printed Page 643
between the two code samples

Under the section titled "Scripted Methods and Objects", there are two code samples. Between these two samples is a single line o
f text reading:

"BeanShell methods may also have dynamic (loose) argument and return types."

This line is printed in the code font (ie "Constant width") rather than the straight-text font, despite it being distinctly NOT cod
e or a comment.

Anonymous   
Printed Page 643
between the two code samples

Under the section titled "Scripted Methods and Objects", there are two code samples. Between these two samples is a single line o
f text reading:

"BeanShell methods may also have dynamic (loose) argument and return types."

The word "argument" should spelled "arguement".

Anonymous