I'm posting here and snap from Book "Java The complete reference". I tried to test the statement made in this snapshot. Result is 20 for both b1 and b2 which shows that objects are linked. But the book says Objects are not linked and any change to b1 should not affect, b2.
Where I am making mistake?
public static void main(String[] args) {
Box b1 = new Box();
b1.width = 10;
b1.height = 20;
b1.depth = 15;
Box b2 = b1;
double vol;
// assign values to mybox1's instance variables
/* assign different values to mybox2's
instance variables */
b1.width = 20;
b1.height = 299;
b1.depth = 15;
System.out.println(b1.width);
System.out.println(b2.width);
}