This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Abstract/Final  Method-local 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 "Abstract/Final  Method-local Inner Class " Watch "Abstract/Final  Method-local Inner Class " New topic
Author

Abstract/Final Method-local Inner Class

Marcelo DeOliveira
Greenhorn

Joined: May 08, 2008
Posts: 27
Does anybody have any good reason to create a abstract or final Method-local Inner class?


a SCJP, almost a SCWCD
Swapnil Sonawane
Ranch Hand

Joined: Jan 02, 2008
Posts: 190
Please modify your name according to Javaranch naming policy.


Swapnil S. Sonawane<br /> <br />B.Tech (Expected May 2009)<br />Computer Science, NIT Durgapur, India<br />SCJA 1.0
Marcelo DeOliveira
Greenhorn

Joined: May 08, 2008
Posts: 27
Swapnil,

I changed! My apologies!
Bob Ruth
Ranch Hand

Joined: Jun 04, 2007
Posts: 320
Marcelo, I am not trying to be trivial in answering your question.... it is just the only thing that comes to mind. Using inner classes within a method like that one can establish a hierarchy of inner classes. I would suppose that an abstract inner class could be inherited by a subsequent inner class. and a final inner class could be instantiated and used further on down in the method.

I am sorry that I can not point to an example but this seems as though it would be a reasonable thing to do.

Bob


------------------------
Bob
SCJP - 86% - June 11, 2009
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

There is no reason why a method-local inner class should not be final. One might consider declaring such a class final to be pointless, but some people like to follow the rule where a class is to be declared final unless it's specifically designed to be subclassed. In this case the rule would usually require a method-local inner class to be declared final.
Marcelo DeOliveira
Greenhorn

Joined: May 08, 2008
Posts: 27
Thanks guys!
 
Consider Paul's rocket mass heater.
 
subject: Abstract/Final Method-local Inner Class