Local Classes

Local classes are classes that are defined in a block, which is a group of zero or more statements between balanced braces. You typically find local classes defined in the body of a method.

Example:

import java.lang.*;
class  Intrest
{      
	void  compareIntrest()  // Start of Method of outer class
	{
		
		 class  Simple
		 {	 
			 
			 double Calculate(double amt,double rate,double time)
			 {
			   double  i=(amt*rate*time)/100;
			   return(i);
			 }	     
		 
		 }	 

		 class  Compound
		 {		 
			 double Calculate(double amt,double rate,double time)
			 {
			   double  i=(amt* Math.pow( (1+(rate/100)), time)) -amt;
			   return(i);
			 }		 
		 }
		Simple si=  new Simple();
		double  r= si.Calculate(1000, 5, 2);
		System.out.println("Simple Interest::"+r);
		
		Compound ci=  new Compound(); 
		r= ci.Calculate(1000, 5, 2);
		System.out.println("Compound Interest::"+r);
		
	} // end of method of outer class
		
}
public class soft 
{	
	public  static void main(String  args[])
	{
		Intrest  outer= new Intrest(); 
		outer.compareIntrest();
	
	}

}

Output is:
Simple Interest::100.0
Compound Interest::102.5