Please note: This page applies almost exclusively to the first edition of Java 2 For Dummies. If you have the second edition visit this page instead.
In the book's first few pages, look for a page with all kinds of official-looking stuff (the publisher's address, the Library of Congress Control Number, the ISBN, and so on). On that page, look for a line with descending numbers on it.
10 9 8 7 6 5 4 3 2
The smallest number is the number of your printing. For instance, the line shown above is in books made during the 2nd printing.
MortgageApplet.java
compiles under Java 1.4, but it doesn't
load and run in Internet Explorer.
There are several things you can do about this:
appletviewer MortgageApplet.html
MortgageApplet
in Netscape Navigator 6, and
it seems to load and run there.
MortgageApplet.class
that I compiled under Java 1.3.
MortgageText.java
MortgageWindow.java
MortgageApplet.java
Thanks to Jeff Goldstein
--
. The
decrement operator is not the single minus sign -
that's used in many
of this section's paragraphs. (This error is fixed in the 2nd
printing.)
For instance, the end of the first full paragraph of that section should read as follows:
"The increment operators use double plus signs (++
), and the decrement
operator uses double minus signs (--
). To see how they work ..."
MakeChange.java
(Listing 4-7), change two occurrences of the word total
to the word whatsLeft
:public class MakeChange { public static void main(String args[]) { int quarters, dimes, nickels, cents; int whatsLeft, total; total = 248; quarters = total/25; whatsLeft = total%25; dimes = whatsLeft/10; whatsLeft = whatsLeft%10; nickels = whatsLeft/5; whatsLeft = whatsLeft%5; cents = whatsLeft; System.out.println("From " + total + " cents get"); System.out.println(quarters + " quarters"); System.out.println(dimes + " dimes"); System.out.println(nickels + " nickels"); System.out.println(cents + " cents"); } }When you make the change, a run of the program looks like this:
Thanks to David Wurster
UseAssignmentOperators.java
(Listing 4-8), swap the two statements
that multiply numberOfBunnies
by 2, and add numberExtra
to
numberOfBunnies
:public class UseAssignmentOperators { public static void main(String args[]) { int numberOfBunnies; int numberExtra; numberOfBunnies=27; numberExtra=53; numberOfBunnies += 1; System.out.println(numberOfBunnies); numberOfBunnies += 5; System.out.println(numberOfBunnies); numberOfBunnies *= 2; System.out.println(numberOfBunnies); numberOfBunnies += numberExtra; System.out.println(numberOfBunnies); System.out.println(numberOfBunnies -= 7); System.out.println(numberOfBunnies = 100); } }
Thanks to Bo Isaksson
InventoryD.java
in Listing 12-4 should have one additional statement
near the end. The additional statement is highlighted in bold below:import java.text.NumberFormat; public class InventoryD { public static void main(String args[]) { String numBoxesIn; int numBoxes; double boxPrice = 3.25; NumberFormat currency = NumberFormat.getCurrencyInstance(); System.out.print("How many boxes do we have? "); numBoxesIn = DummiesIO.getString(); try { if (numBoxesIn.equals("")) throw new NoInputException(); numBoxes = Integer.parseInt(numBoxesIn); if (numBoxes < 0) throw new NegativeNumberException(); System.out.print("The value is "); System.out.println (currency.format(numBoxes*boxPrice)); } catch (NegativeNumberException e) { System.out.print(numBoxesIn); System.out.println("? That's impossible!"); } catch (NumberFormatException e) { System.out.println("That's not a number."); } catch (Exception e) { System.out.print("Something went wrong, "); System.out.print("but I'm clueless about what "); System.out.println("it actually was."); } System.out.println("That's that."); } } class NegativeNumberException extends Exception { } class NoInputException extends NumberFormatException { }Thanks to the Java students from Toys R Us
Drawing.java
file is in Listing 13-3.
The Drawing.java
file is not in Listing 13-3. The Drawing.java
file is in Listing 13-2.Thanks to Tom Cavaiani
The most recent version of the MRJ implements an older version of Java - Java 1.1.8. So some of the code in Java 2 For Dummies won't work under the MRJ. I've created a revised version of DummiesIO.java that works with the MRJ. When you compile it, you'll get a deprecation warning, but the warning doesn't stop you from running the code.
Also, please note: To be able to read from the keyboard (as in MortgageText.java, from Chapter 2), you have to tweak the MRJ settings. There's a picture illustrating what you have to do at http://rescomp.stanford.edu/~ejalbert/faqs/stdin.html.
Thanks to Andrew Beckman and John Muccigrosso
Visit the book's page at Hungry Minds.
If you have any comments or questions for Barry Burd, please send email to j2fd at BurdBrain.com. Thank you.