• Post Reply Bookmark Topic Watch Topic
  • New Topic

Object creation  RSS feed

 
Gajendra Kangokar
Ranch Hand
Posts: 94
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

in the above code when 'v' is made to point to second object is b1 still refering to 1st object?
is it like.. a object is created inside the 1st object?
Thank you
 
Tony Docherty
Bartender
Posts: 3271
82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it like.. a object is created inside the 1st object?

Not in this case although objects are regularly created inside other objects. In the code shown the first instance of B1 holds a reference to the second instance of B1.
 
Ivan Jozsef Balazs
Rancher
Posts: 999
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After the two consturctors:
b1 -> (B).v -> null; //object 1
b2 -> (B).v -> null; //object 2

After the assignment:
b1 -> (B).v -> b2l;
b2 -> (B).v -> null;
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!