Originally posted by Ganeshkumar cheekati:
can you giv explanation for A d=new A().aob=new A(); ?
is nt object referenced by d.aob?
Statement: A d=new A().aob=new A(); Note, above statement can be written as below:
A d=
(new A().aob=new A()
);
That means, the bracketed expression will be evaluated at first. Inside this expression, a new object will be created by the below
italic expression:
A d= (
new A().aob=new A());
And then, another object will be created by the following
bold expression, and it will be assigned to the "aob" attribute of the above object:
A d= (
new A().aob=
new A());
Finally, the result of the above bracketed expression will be assigned to the variable 'd'. Note, the result of the bracketed expression is the above
bold object. Then the object in
italic mode is eligible to GC.