GeeCON Prague 2014*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Method local inner classes - conclusion 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 "Method local inner classes - conclusion" Watch "Method local inner classes - conclusion" New topic
Author

Method local inner classes - conclusion

Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 355

Inner classes are like a full fledged member of the enclosing class.
Similarly, can we conclude that a method-local inner class is like a local variable? Further, can we treat it like a local variable?
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18876
    
  40

Similarly, can we conclude that a method-local inner class is like a local variable? Further, can we treat it like a local variable?


Not sure what you mean by treating a inner class like a local variable. One is a class definition and the other is a reference variable. You can certain assign an instance of an method inner class to a local variable, but you can also assign this instance to a instance or class variable too (Although, in these later cases, you will need to hold it in a super class to the inner class, as the inner class type will not be in scope).

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Faisal Ahmad
Ranch Hand

Joined: Aug 31, 2006
Posts: 355

Oops...it should've been 'local member'!
Sorry for the mistake.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Method local inner classes - conclusion