Method Local Inner Class

What is method local inner class? 

Sometimes we can declare a class inside a method such type of classes are called method local inner classes.

The main purpose of method local inner classes is to define method specific functionality.

The scope of method local inner classes is the scope of the method where it is declared.

This is the mostly rarely used type of inner classes.


class Test{

      public  void  m1(){

               class Inner {

                               public void sum(int I,int j){




            Inner  i=new Inner();


            //more code here  


           //more code here 



   Public  static  void main(){

      New Test().m1();



See also
Hot Key Instead Of Key Listener

Do you have a Java Problem?
Ask It in The Java Forum

Java Books
Java Certification, Programming, JavaBean and Object Oriented Reference Books

Return to : Java Programming Hints and Tips

All the site contents are Copyright © and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of or the content authors.