Method local inner classes
1. Declaring the class inside the method is called method local inner classes.
2. In the case of the method local inner classes the class has the scope up to the respective method.
3. Method local inner classes do not have the scope of the outside of the respective method.
4. whenever the method is completed
5. we are able to perform any operations of method local inner class only inside the respective method.
Syntax:-
class Outer
{
void m1()
{
class inner
{
};
}
};
Method local inner classes program
class Outer 
{ 
private int a=100; 
void m1() 
{ 
class Inner 
{ 
void innerMethod() 
{ 
System.out.println("inner class method"); 
System.out.println(a); 
} 
}; 
Inner i=new Inner(); 
i.innerMethod(); 
} 
}; 
class Test 
{ 
public static void main(String[] args) 
{ 
Outer o=new Outer(); 
o.m1(); 
} 
};
Output :
inner class method
100