Hi Baseet,
I tried creating one and was able to create it, but i wish to know is there any real world scenario which would need a scenario like this???
Here is my sample program....
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 extends java.lang.Thread
{
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)
{
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();
}
}
The output is :
---------------
The value of the return value is :18
Calling the Outermost Constructor
Calling the MyInner Constructor
The value of the 'x' is :6
Calling the Outermost Constructor
Calling the MyInner Constructor
Calling the MyInnerMost Constructor
The 'name' selected for $1 million d
Press any key to continue . . .