Guys
Pl go thru the code below that I have written It's crazy..I accept.But I started to try out few things and evolved with more questions.As you might have guessed,the questions are at the end.
public class Test{
static int num=0;
public
Test(){
System.out.println(num+"--from outer constructor");
}
public static void main(
String args[]){
String s[]={"from"," outer"};
System.out.println("HI");
Inner i=new Inner();
i.main(s);
num+=1;
System.out.println(num+"--from outer main");
}
public static void getOut(){
System.out.println("Good Bye");
System.exit(0);
}
public static class Inner{
public Inner(){
System.out.println(num+"--from inner constructor");
}
public static void main(String args[]){
String s1[]={"from"," inner"};
System.out.println("HI from inner");
Test t=new Test();
num+=1;
System.out.println(num+"--from inner main");
if (num>02)
t.getOut();
t.main(s1);
}
}
}
Following are the questions.
1.In continuation of my experiments with static inner class,How can a static instantiate with constructor??How does it behave--accessig its methods etc..and its use as static.
2.Calling main() method.Is it valid everywhere??.I really lost here.Two main,both static excecuting as normal methods.
3.With objects being created and re-created to the same reference for both outer and inner,which are all the eligible candidates for garbage collection and How may objects get collected when exited??
Let me stop here to contain your patience.
PS:Paul, you see here the instansiation static inner class here as you said.
Thanx