Owl Sams Teach Yourself Java 2 in 21 Days

Day 2: A Taste of Object-Oriented Programming

NOTES AND CORRECTIONS

  • Line 15 of Listing 2.2 is incorrectly formatted over two lines. If you're having trouble creating a version of the program that will compile, replace Line 15 with the following correctly formatted source code:
    • System.out.println("This is a " + sex + " " + color +
      • " jabberwock.");
  • On Page 47, the description of the Jabberwock application's main() method contains a typo. The Jabberwock object is created in line 23 of the program, not line 2.

SOURCE FILES

READER QUESTIONS

  • Q: There's a difference between yesterday's HelloDan class and today's Jabberwock class that I don't understand. In the public static void main() statements for these programs, why does one have String[] arguments within the parenthesis, and the other has String arguments[]? -- J.S.
  • A: We're getting ahead a bit, but the difference is because arrays can be created in two ways -- by putting the brackets next to the class or data type, as in String[] arguments, or putting them next to the variable name, as in String arguments[]. It's a matter of personal preference which to use, though I was striving to use the String[] arguments style consistently in this book (in other words, oops). This subject is covered in full during Day 5, "Lists, Logic and Loops."

LINKS

BOOKS