Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Inner Class

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From
Corey McGlone's Blog The SCJP Tipline

Need further explanation on statement

While each inner class has a reference to its enclosing class, the reverse is not true (at least not implicitly). A single enclosing class can have one, two, three, or even hundreds of inner classes associated with it.
Unless you declare a reference from the enclosing class to its inner class(es), it has no reference to them.

Thanks,

Vidya
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's an article on the Sun Developer Network that is very relevant to this question called Do inner classes have direct access to instance variables and methods of the outer class? Have a look at it as I think that it will answer your questions.

/Pete
 
Ranch Hand
Posts: 62
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Vidya,

I think the code below has an example of what McGlone was trying to say:



Marcos.
 
Ranch Hand
Posts: 1710
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vidya,

See the code below to have idea of following line:

A single enclosing class can have one, two, three, or even hundreds of inner classes associated with it.




[ April 29, 2007: Message edited by: Chandra Bhatt ]
 
Vidya Singh
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks,
 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Vidya wrote:
While each inner class has a reference to its enclosing class, the reverse is not true (at least not implicitly). A single enclosing class can have one, two, three, or even hundreds of inner classes associated with it.
Unless you declare a reference from the enclosing class to its inner class(es), it has no reference to them.



Here is an eg.
 
Barry's not gonna like this. Barry's not gonna like this one bit. What is Barry's deal with tiny ads?
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic