aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Nonstatic nested class execution doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Nonstatic nested class execution doubt" Watch "Nonstatic nested class execution doubt" New topic
Author

Nonstatic nested class execution doubt

Shiva Mohan
Ranch Hand

Joined: Jan 05, 2006
Posts: 479



Output is A1B0A0B1A2B2 .Starting itself I am getting trouble that getting value is A0.
How the starting value A1 is coming. It might end up like silly doubt. But I couldn�t figure it out.
Shiva Mohan
Ranch Hand

Joined: Jan 05, 2006
Posts: 479
I figured it out. Ppp() is called first time by this ppp myA=new ppp();
Then calling m1()���
Thanks.
prarthana reddy
Ranch Hand

Joined: Jul 24, 2006
Posts: 48
Hi Shiva,
I could understand the output A1B0 ( the first part of answer) . Could you please explain the remaining part of the answer ?I also have one more doubt.
new ppp().new B() ( //line 4 ) . Will this create an instance of B alone or ppp too ?

Thanks in advance
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809
new ppp().new B() ( //line 4 ) . Will this create an instance of B alone or ppp too ?



Class B is an inner class. When you create an instance of B, it requires an instance of Outer class here ppp, so both objects will be created. writing simply new B() in main method is wrong.

Naseem


Asking Smart Questions FAQ - How To Put Your Code In Code Tags
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Nonstatic nested class execution doubt