aspose file tools*
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
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?