• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Sybex 816 Chapter 1 typo Exam Essentials

 
Bartender
Posts: 1737
63
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: 493
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: 77546
372
  • 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: 493
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
Bartender
Posts: 1737
63
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: 41578
881
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.
 
New rule: no elephants at the chess tournament. Tiny ads are still okay.
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic