This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes My post lost..so once again ques from K&B(local class) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "My post lost..so once again ques from K&B(local class)" Watch "My post lost..so once again ques from K&B(local class)" New topic
Author

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

Amit Das
Ranch Hand

Joined: Mar 05, 2005
Posts: 206
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

Joined: Mar 05, 2005
Posts: 206
is there anyone who can help me out..???
Saranyan Narayanan
Ranch Hand

Joined: Mar 12, 2003
Posts: 34
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: My post lost..so once again ques from K&B(local class)
 
Similar Threads
Doubts regarding Method Local Inner Class
needs explanation
Final variable access from class inside function
Code for Method-Local Inner Classes not compiling
Inner classes