Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Sybex 816 Chapter 1 typo Exam Essentials

 
Saloon Keeper
Posts: 1672
61
Eclipse IDE Postgres Database C++ Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the roundup for "Be Able To Declare and Use Nested Classes" we say "such as calling new Outer.new Inner()"

I never seem to do this often enough to remember the syntax, so I am glad you guys agree that it may never stop looking weird.

But having recently reviewed the chapter I realized it should say:
"such as calling new Outer().new Inner()"

I just confirmed it by writing a quick test case as well.
 
Ranch Hand
Posts: 477
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesse Silverman wrote:But having recently reviewed the chapter I realized it should say:
"such as calling new Outer().new Inner()"


Agreed.  Thanks for the heads up!
 
Marshal
Posts: 74393
335
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesse Silverman wrote:. . . new Outer().new Inner() . . . .

That is the usual idiom for instantiating a non‑private inner class. For a static nested class, you usually write new Outer.Inner(). Find a copy of Thinking in Java by Bruce Eckel (2nd or 3rd editions), which explains nested classes nicely.
 
Charles O'Leary
Ranch Hand
Posts: 477
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:

Jesse Silverman wrote:. . . new Outer().new Inner() . . . .

That is the usual idiom for instantiating a non‑private inner class. For a static nested class, you usually write new Outer.Inner(). Find a copy of Thinking in Java by Bruce Eckel (2nd or 3rd editions), which explains nested classes nicely.



I think the OP successfully highlighted the typo.  Full context of the summary at the end of the chapter for those that do not have the book (but I may add, should pick it up yesterday):

Be able to declare and use nested classes. Instantiating an inner class requires an instance of the outer class, such as calling new Outer.new Inner(). On the other hand, static nested classes can be created without a reference to the outer class, although they cannot access instance members of the outer class without a reference. Local and anonymous classes cannot be declared with an access modifier. Anonymous classes are limited to
extending a single class or implementing one interface.

 
Jesse Silverman
Saloon Keeper
Posts: 1672
61
Eclipse IDE Postgres Database C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Charles: please note, I love Scott, Jeanne and the book.
I even still love Java.
The certification experience feels like a tricky sneaky lawyer had just announced his plan to become a Java programmer right before his car crashed and he found himself in Hell.
I'll get there.  (Certification, hopefully not Hell.)
 
author & internet detective
Posts: 40847
829
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh no! The parens ran away! I've added this to the errata. Thank you for noticing and letting us know.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic