This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes What is use of Local inner classes? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What is use of Local inner classes?" Watch "What is use of Local inner classes?" New topic

What is use of Local inner classes?

minal silimkar
Ranch Hand

Joined: Nov 25, 2007
Posts: 133
Inner classes in code blocks, such as method body, constructor or initialization block is known as Local Inner Classes.

As local inner classes are completely inaccessible outside the method.

If you are defining any local variable you can not access those variables outside the method.

Then what is the use of Local Inner classes?

Minal Silimkar
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38033
Most commonly to start a Runnable, or a Listener in Swing. Have a look at this old thread.
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112
Do you know what anonymous inner classes are good for?

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
I agree. Here's the link:
subject: What is use of Local inner classes?
Similar Threads
Inner class
Local Inner Class Instantiation
Method local inner classes
Declare non-static "local class" within static method
Method Local Inner Class Pg 671 Kathy Sierra and Bates SCJP 6