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


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "inner class" Watch "inner class" New topic
Author

inner class

Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521


this is from K&B....why is 2 printed and not others? couldnt understand the books explanation...declaration of class A comes after creating the instance of A..so what?


scjp 1.6 91%, preparing for scmad
"Time to get MAD now.. we will get even later"....by someone unknown
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
look that is a method local inner class so how can you create its instance before declaring it, what I mean is in a method how can you use something that has not yet been declared. but the other(regular) inner class's instance can be created. which will be accessed.


I hope its the correct reason.


SCJP 1.6 96%
Raju Champaklal
Ranch Hand

Joined: Dec 10, 2009
Posts: 521
if there was no method local inner class and just the other two classes(one the outer and one the inner) then the inner one would be accessed because the inner one is closely associated with the TestInners class...

is this explanation right?
Neha Daga
Ranch Hand

Joined: Oct 30, 2009
Posts: 504
yes.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: inner class