|
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
Do you have a Java Problem?
Java Books
Return to : Java Programming Hints and Tips All the site contents are Copyright © www.erpgreat.com
and the content authors. All rights reserved.
|