Learning Java, 2nd Edition by Pat Niemeyer, Jonathan Knudsen This errata page lists errors outstanding in the most recent printing. If you have technical questions or error reports, you can send them to booktech@oreilly.com. Please specify the printing date of your copy. This page was updated February 1, 2005. Here's a key to the markup: [page-number]: serious technical mistake {page-number}: minor technical mistake : important language/formatting problem (page-number): language change or minor formatting problem ?page-number?: reader question or request for clarification Confirmed errors: (11) 4th paragraph; The word 'runtime' is broken at the end of the line as 'runt-ime'; it should be broken 'run-time' (43) 1st and 3rd paragraphs; In the first paragraph, the line that says 'HelloJava2 newobj = new HelloComponent2("Hello Java!"); It should say 'HelloComponent2 newobj = new HelloComponent2("Hello Java!");' There is a similar error in the third paragraph. (67) 5th paragraph (just before "System Properties" heading); Missing space before "method" in "The java interpreter continues to run until the main()method of the initial class file returns..." (77) output for "jar tvf spaceblaster.jar"; The first line of the output is incorrectly indented, so it doesn't line up with the other lines. {108} near top of page; There should be a semicolon (;) at the end of line for the following code sample assert a > 0 : a assert foo != null : "foo is not null!" (108) last 2 command line examples and last paragraph; The examples should have a class to execute. Instead of % java -ea:com.oreilly.examples.Myclass it should be % java -ea:com.oreilly.examples.Myclass MyApplication And instead of % java -ea:com.oreilly.examples... it should be % java -ea:com.oreilly.examples... MyApplication Also, there is a missing "a" before "package" in the last paragraph. Instead of "When you enable assertions for package, Java also enables all subordinate package names..." it should be "When you enable assertions for a package, Java also enables all subordinate package names..." {109} middle of page; missing semicolon (;) at end of doRight() (119) 3rd paragraph; The word "zero" is not a keyword or variable, so it shouldn't be set in monospace font in "...it's given a default value appropriate for its type (null, zero, or false)." (130) 4th paragraph; "We'll talk about method overriding later in the chapter." should say: "We'll talk about method overriding in the next chapter" (160) 3rd paragraph; "the table doesn't addresses that scope" should read "the table doesn't address that scope" {196} 2nd paragraph; The text incorrectly refers to an instance method sleep(), when in truth there are only two static sleep() methods. [232] 4th paragraph; (probably typo, but serious error anyway) text: You can retrieve the default Locale ... with the static Local.getDefault() method. should be: ... with the static Locale.getDefault() method. {258} Table 10-4; In Table 10-4 nextFloat() returns a random float from 0.0 inclusive to 1.0 exclusive, not from -1.0 to 1.0 as listed nextDouble() returns a random double from 0.0 inclusive to 1.0 exclusive, not from -1.0 to 1.0 as listed nextGaussian() should be clarified as returning a Gaussian distributed double value with mean 0.0 and standard deviation 1.0. Only the standard deviation is mentioned, and the type returned is not stated. (At the top of page 259 the appropriate clarifications for nextGaussian() are made.) (305) 2nd paragraph under File Options "...getPath() returns the directory information without the filename." should be: "...getPath() returns the directory information and the filename." [304] last but one paragraph; "the Swing JFileDialog class" should say: "the Swing JFileChooser class" {306}: Collections.sort(l); should be Collections.sort(list); (307) Table 11-1; The method for creating multiple directories in a path is written as Mkdirs(), this should be lowercase, mkdirs(). {370} Third sentence in first paragraph; The text says that "Each call to select() returns the set of SelectionKeys that are ready for some type of I/O'. This is incorrect. Instead, select() returns the number of keys which are ready for some type of I/O. The selectedKeys() method returns the Set of SelectionKeys that are ready for I/O. {374} 8th line in write() method; The test to determine if the file has been completely read is incorrect. It should be if (got == remaining) rather than if (got == -1 || remaining <= 0) (405) Middle of the 3rd text paragraph; In line 6 of the 3rd paragraph: ... getValue() gives us a null array ... This should say "getAttribute()", not "getValue()". {406} Next to last paragraph, last sentence; The text says "Indicating a negative time period is a good way to erase an existing cookie of the same name". This is incorrect. Indicating a time period of 0 will erase an existing cookie; indicating a negative time period will not affect existing cookies of the same name. (502) 1st paragraph under "Validating Data"; Where it says "Java 1.4 added the InputVerifier API" it should say "Java 1.3 added the InputVerifier API" Sun's Javadocs and other resources mention that InputVerifier was added with 1.3. {506} Figure 17-4; The figure is from Microsoft Internet Explorer for Mac and not the CanisMinor Application. {692} Public Class SimpleElement; The public method public void addText(String s) {... should be public void setText(String s) {... {694} public void characters() method; The public void characters() method uses .addText(text); This should be .setText(text);