This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes why private member variable of inner class can't be accessed by its outer class but mehod can be? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "why private member variable of inner class can Watch "why private member variable of inner class can New topic
Author

why private member variable of inner class can't be accessed by its outer class but mehod can be?

Divyya Joshi
Ranch Hand

Joined: Jul 15, 2010
Posts: 102
The following code is related to regular inner class and the moment i try to access private member variable of inner class compiler complains error but Not when private member is acessed
Here's the code



Anyone kindly explain this absurd behaviour .
Piyush Joshi
Ranch Hand

Joined: Jun 10, 2011
Posts: 207

Divyya Joshi wrote:



what is the type of x here??

I think you forgot to write int here:



Piyush
Divyya Joshi
Ranch Hand

Joined: Jul 15, 2010
Posts: 102
Yeah Thanks Piyush..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why private member variable of inner class can't be accessed by its outer class but mehod can be?
 
Similar Threads
why private member variable of inner class can't be accessed by its outer class but mehod can be?
Inner Classes Q
Regular Inner class
Inner Class question..
inner class instantiation from outside the the outer class