• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inner class

 
Raju Champaklal
Ranch Hand
Posts: 521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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?
 
Neha Daga
Ranch Hand
Posts: 504
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Raju Champaklal
Ranch Hand
Posts: 521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 504
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic