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.
 

Example:

class Test{

      public  void  m1(){

               class Inner {

                               public void sum(int I,int j){

                  System.out.println(i+J);

            }//sum

             }//inner

            Inner  i=new Inner();

            i.sum(10,20);

            //more code here  

           I.sum(100,303);

           //more code here 

         i.sum(102,84);

        }//m1()

   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 © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com 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
www.erpgreat.com or the content authors.