package examples.inner; /** A class definition to explore the use of local * inner classes */ public class Equation1 { private int equationInput; /** An interface defining the result from an * equation */ public interface Result { public double getAnswer(); } /** Constructor method * @param ei the equation input */ public Equation1( int ei ) { equationInput = ei; } /** Create the result of the equation for the given * input values * @param input1 the first equation input * @param input2 the second equation input * @return the result object */ public Result getResult( final int input1, final int input2 ) { final int [] localVar = { 2,6,10,14}; class MyResult implements Result { private int normalField; public MyResult() { normalField = 2; } public double getAnswer() { return (double) input1 / input2 - equationInput + localVar[2] - normalField; } } return new MyResult(); } /** The test method for the class * @param args not used */ public static void main( String[] args ) { Equation1 e = new Equation1( 10 ); Result r = e.getResult( 33, 5 ); System.out.println( r.getAnswer() ); } }