Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

My post lost..so once again ques from K&B(local class)

 
Amit Das
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

K&B Ch 8(Inner Classes page 466)
But even after the method completes,
the inner class object created within it might still be alive on the heap if, for
example, a reference to it was passed into some other code and then stored in an
instance variable


how do we do this. I tried to do sth like this:


how is it possible to have an object of rutime-type object as that of the inner class or may be its extension as in the case mentioned above???

also i'm not able to understand the o/p of this line:
System.out.println(mi.getClass().getName()); //MyOuter2$1 ???

why i'm not geeting anything like MyInner$1???

and since i'm catching the argument-local anonymous class, polymorphically as type Object, how can we say that the oject created inside the method outlives the method invocation???

plz help me out??

thanx
amit
 
Amit Das
Ranch Hand
Posts: 206
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there anyone who can help me out..???
 
Saranyan Narayanan
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can see it as
1) this here used to invoke check is seen as a MyOuter because of ch being invoked as an object of MyOuter.
I hope this answers part 1
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic