aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Inner Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Inner Class" Watch "Inner Class" New topic
Author

Inner Class

Vidya Singh
Greenhorn

Joined: Mar 21, 2007
Posts: 28
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
pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
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
Marcos R Oliveira
Ranch Hand

Joined: Apr 20, 2002
Posts: 51
Hi, Vidya,

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



Marcos.


SCJP 1.4 - SCJP 1.6 - SCWCD in progress
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
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 ]

cmbhatt
Vidya Singh
Greenhorn

Joined: Mar 21, 2007
Posts: 28
Thanks,
Meena R. Krishnan
Ranch Hand

Joined: Aug 13, 2006
Posts: 178
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Inner Class