Hi I have one doubt regarding Inner class... This is different than the other topic though... Can I create an Inner Class for a INNER class?? what will happen if I create and what is the use of it???
I tried creating it and was able to create one, but I wish to know is there any real world scenario which would need this kind of coding....
The sample example is given below:
import java.util.*;
import java.lang.*;
public class MyOuter implements java.io.Serializable
{
private int x = 6;
private
String name = "Humpty Dumpty";
public MyOuter(){System.out.println("Calling the Outermost Constructor");}
public MyOuter(String arg){}
public double seeCurrent()
{
float f = 3.1416f;
Double d = Double.valueOf(f*x);
return d;
}
class MyInner
{
public MyInner(){System.out.println("Calling the MyInner Constructor");}
public void seeOuter()
{
System.out.println("The value of the 'x' is :"+x);
}
class MyInnerMost
{
public MyInnerMost(){System.out.println("Calling the MyInnerMost Constructor");}
public void seeOuterMost()
{
System.out.println("The 'name' selected for $1 million dollar is:"+name);
}
}
}
public static void main(String[] are) throws java.lang.Throwable
{
System.out.println("Before creating any instance in the main method");
Double value = null;
MyOuter mo = new MyOuter();
value = mo.seeCurrent();
System.out.println("The value of the return value is :"+value);
MyOuter.MyInner mi = new MyOuter().new MyInner();
mi.seeOuter();
MyOuter.MyInner.MyInnerMost mim = new MyOuter().new MyInner().new MyInnerMost();
mim.seeOuterMost();
}
}