PPT Slide
L=3, W=9, H=2
Objects and References
Assignment with References to Objects:
Code: Memory:
Box box1;
Box box2;
box1
box2
box1 = new Box(8, 5, 7);
L=8, W=5, H=7
box1 box2
box2 = box1;// note: two references// but only one object
box1box2
box1 =
new Box(3, 9, 2);
box1box2
box1 = box2;
// Old reference lost!
box1box2
L=8, W=5, H=7
L=8, W=5, H=7
L=3, W=9, H=2
L=8, W=5, H=7
Previous slide
Next slide
Back to first slide
View graphic version