Saturday, February 28, 2009

static nested class using inner main,outer main method



package innerclass;


public class Test
{
static class Inner
{
public void m1()
{
System.out.println("hai");
}
public static void main(String att[])
{
Inner i=new Inner();
i.m1();
System.out.println("inner main");
}
}
public static void main(String art[])
{
Test.Inner in =new Test.Inner();
in.m1();
System.out.println("outer main");
}

}

here we can run by using outer class main and inner class main
output:
run by using outer class main: java Test$1:
hai
outer main
run by using outer class main: java Test$Inner:
hai
inner main



0 comments:

Post a Comment