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 36
Halfway down the page

Missing "import javax.swing.*;" before "import java.awt.*;". If you place the HelloComponent in its own file the java compiler will not find JComponent as it is not in the java.awt name space.

Anonymous   
Printed Page 39
diagram at top of page

The "HelloJava1" class in the diagram should be "HelloComponent." This is because in the example code, HelloJava1 never inherits from JComponent, HelloComponent does.

Anonymous   
Printed Page 39
Figure 2-2

HelloJava1 is shown. This should be HelloComponent.

Anonymous   
Printed Page 49-51
example code

The supplied code on pages 49 to 51 for program called HelloJava3 does not compile. Neither the example downloaded from the webpage or the code printed in the book. Netbeans complains about the class HelloComponent not beeing an abstract class and that it cannot override abstract method actionPerformed in java event actionListener.

Anonymous  Feb 12, 2012 
Printed Page 79
code snippet near bottom of page

The code snippet involves creating a socket with the IP address: 207.46.131.13. When I tried the example it failed to connect; in fact, I couldn't even ping that address. Consider using a URL that's more likely to be always-on (e.g., www.google.com). I tried www.google.com instead and it worked.

Note from the Author or Editor:
to fix this we'd have to fix the images... let's defer.

Anonymous   
Printed Page 86
Table 4-1

States that @since only applies to variables, but I think that it also applies to classes and methods as well.

Stephen  Dec 07, 2009 
Printed Page 246
3rd paragraph, 2nd Sentence

Says: It tests, first, whether window.getComputedStyle is supported, and if not, tests for getComputedStyle. Should say: It tests, first, whether obj.currentStyle is supported, and if not, tests for window.getComputedStyle.

Anonymous   
PDF Page 264
2nd paragraph under the section "Why Isn't a List<Date> a List<Object>?"

You write: "In the simplest case, supposing an ObjectList type extends a DateList type, the DateList would have all of the methods of ObjectList [...]" ObjectList and DateList should be switched to render: "In the simplest case, supposing a DateList type extends an ObjectList type, the DateList would have all of the methods of ObjectList [...]" (This was already reported, but remains unconfirmed because of the erroneous page number. The page number given is for the 4th edition of the book; I have also confirmed this error in the 3rd print edition, on page 224.)

Lane Surface  Jan 02, 2019 
Printed Page 267
public class Producer implements Runnable{

Was under the assumption that the Producer class was an inner class of Consumer (no import statement(s) before class declar... I removed the public class modifier and the app. ran as expected; however, I checked the examples that came on the CD and see that they were separate class files; I'm not sure if I just read it wrong or if the example is a little unclear.

Anonymous   
Printed Page 267
"main" method - middle of page

Producer and Consumer are printed as two public classes in one file. Java won't compile this file because it is looking for two separate public classes. Although your downloaded example splits this into two class files, page 268 says: "You can run the example as follows:..." Confusing to the novice programmer.

Anonymous  Feb 15, 2012 
Printed Page 268
getMessage() method

In the while loop of the getMessage() method, you call a notify(). This is probably useless. Notify can only wake up the producer as getMessage() is only called by the consumer. The producer goes to wait when the queue has more than five messages. The condition to enter the while loop is an empty queue. Both conditions are never met together.

Pierre Nugues  May 28, 2009 
PDF Page 273
Third paragraph under "Bounded Wildcards"

(Page 233 in the printed version of the third edition. Location given above is for the fourth edition.) "Wildcard bounds may extend interfaces as well as use the & syntax to add interface requirements to the bound: `Trap< ? extends Catchable & Releaseable > trap;` In this case, the instantiation serves as a supertype of the set of instantiations on types implementing both the Catchable and Releaseable interfaces." This section is incorrect--wildcard bounds are restricted to a single type. It should be changed to reflect this.

Lane Surface  Jan 03, 2019 
Printed Page 341
It's missing!

My copy brought several months ago in the UK contains pages 1-340 (ie chapters 1-10) then pages 293-340 (chapter 10 *again*) then continues from page 389 (chapter 12), chapter 11 is missing :( Other chapters might be affected I've yet to read them. I went to my local bookstore today to get a correct printing but all copies they had were also affected - they have contacted the distrubitor and I am awaiting a phone call to see if they can get a correct printing.

Anonymous   
Other Digital Version 400
Location 8975 of 38331 (Kindle version)

In the section "Why isn't a List<Date> a List<Object>, you write: ..., supposing an ObjectList type extends a DateList type, the DateList would have all of the methods of ObjectList ... I think you should have written: ... supposing a DateList type extends an ObjectList type ... (I gave a false page number above, as the online form requires a page number but my e-book version does not display page numbers)

sheeptick  Apr 24, 2012 
PDF Page 410
In Class ListIt example

Line # 5 contains "File file = new File(args[0]);" Line # 14 contains "for(String file : files)" This causes a syntax error with the compiler: "file is already defined in main(java.lang.String[]) for (String file : files)" Changed Line #14 to "for(String curfile: files)" and Line #15 from "System.out.println(file);" to "System.out.println(curfile);". It compiles correctly with this change.

Jeffery E. Bell  Jul 26, 2011 
Printed Page 411
first example

Two logical lines have unmatched types: FileInputStream xOut = new FileOutputStream(...); where x is 'foo' or 'pwd' Should be: FileOutputStream xOut = new FileOutputStream(...);

Roger R  Aug 20, 2011 
Printed Page 415
code in 3rd paragraph

BufferedReader bufferedCharsIn = new BufferedReader( inReader ); inReader should be charsIn ?

yantao zhang  Oct 06, 2017 
Safari Books Online 510
First Code snippet

In this snippet. frame.getFocusTraversalKeys( KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS ); AWTKeyStroke ks = AWTKeyStroke.getAWTKeyStroke( KeyEvent.VK_N, InputEvent.CTRL_DOWN_MASK ); Set new = new HashSet( old ); /// WRONG set.add( ks ); frame.setFocusTraversalKeys( KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS,set); I believe the line marked /// WRONG should read: Set set = new HashSet(old); rather than Set new ....

Anonymous  May 21, 2012 
Printed Page 697
example program Iguana.java

This is really a question about the eclipse IDE. The Iguana program on page 697 runs correctly when run from the command line, but not when run within eclipse. The image "Piazza di Spagna.small.jpg" does not display when the program is run from within eclipse. My question is whether I may post the code on an eclipse forum and have someone look at it. I am trying to develop a program that displays images similar to Iguana, so this issue is important to me. Thank you.

Doug Wong  Dec 01, 2009 
Printed Page 850
SAX Example -Chapter 24

Page number might be incorrect. I am viewing this on the Oreilly book shelf and cannot see page numbers. This is the SAX example in chapter 24. I have downloaded the code as well as copy and pasted and I am getting the same error: SimpleElement: No attributes allowed.

Anonymous   
Printed Page 872
1st paragraph ("Building the Ant-Based Examples")

The penultimate sentence of this paragraph directs users to build the magicbeans.jar file from Chapter 22 by navigating in Eclipse's Package Explorer pane to "ch22/learningjava/build.xml". The path to this file is actually "ch22/magicbeans/build.xml".

Anonymous   
Printed Page 903ff
entire index - especially pages 903-907; 927-934; etc.

More of an annoyance than an error: when looking for something in your index, I often at first mistake some lengthy sub-index list (e.g. those under the index entries for "classes" and "methods") for the top-level index itself. This could easily be avoided if you would adopt the convention of preceding each sub-index entry with a dot for each level of indentation - this making it immediately obvious the level of sub-index for any line. For example,the index entries under "class" would look something like: classes, 5, 563-569 . 2D API, 689 . . drawing, 712-720 . . filling shapes, 700 etc. . . viewing images, 707-712 . AbstractFormatter, 626 . AbstractTableModel, 645 With this sort of visual clue, I would not be as likely to waste time by opening to the middle of the index and begin searching alphabetically for a top-level entry in the middle of the "classes" sub-entries.

Anonymous