swati aole wrote:Hi all experts..
I am new to java ranch... I tried invoking the inner class constructor() inside the main class constructor and it worked properly.
How come?? I thought we need outer obj to create inner obj so the compilation might fail..
please send some explanation.
Thanks in advance.
here is the code:
class testC
{
testC(){
new inner();
}
public class inner{
void show(){}
}
}
I am invoking the inner class constructor inside the outer constructor and it compiled ... but we need an outer obj to create inner obj ... so how can we create the inner obj before outer constructor generated an outer obj..
Thanks.
no I am not from mumbai and it would be great if anybody could send some explanation on this topic..