I'm reading this book on data structures and it covers memory management and orphaned objects in Java.The textbook says the following:
For example, consider the three assignment statements in the figure at left. After the third assignment statement, not only do a and b refer to the same Date object (1/1/2011), but also there is no longer a reference to the Date object that was created and used to initialize b. The only reference to that object was in the variable b, and this reference was overwritten by the assignment, so there is no way to refer to the object again. Such an object is said to be orphaned.
Code:
Date a=new Date(12, 31, 1999);
Date b=new Date(1, 1, 2011);
b=a;
Is that statement true? Shouldn't the reference of a (the memory location of object Date(12, 31, 1999) be what the reference of b be? This seems like one huge error but there is even a picture showing memory block for 12, 31, 1999 being the orphaned object.
Picture: http://imageshack.us/f/818/3tkx.jpg/
a = b;for there statement to be true.