• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

Sybex 816 Chapter 1 typo Exam Essentials

 
Ranch Hand
Posts: 47
3
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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: 415
8
  • Mark post as helpful
  • send pies
  • 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: 70982
291
  • Mark post as helpful
  • send pies
  • 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: 415
8
  • Mark post as helpful
  • send pies
  • 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
Ranch Hand
Posts: 47
3
  • Mark post as helpful
  • send pies
  • 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: 40282
819
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic