I think you are misunderstood by how reference and objects works
Main Function
CardBoard c1 = new CardBoard();
c1 |100| Address ---points to---> Memory address at location 100
CardBoard c2 = new CardBoard();
c2 |400| Address ---points to---> Memory address at location 400
CardBoard c3 = c1.go(c2);
c3 |600| Address ---points to---> Memory address at location 600
System.out.print(c2.story); // dout here
go Function
CardBoard go(CardBoard cb) {
cb |400| Address ---points to---> Memory address at location 400
New cb reference is created which also points to memory location where c2 is pointing(Note, cb and c2 are two different reference but pointing to same memory location)
cb = null;
Above line changed cb reference to null, still c2 is pointing to same memory location.
return cb;
}
So when go function returned there is no change to c2.
Try changing story variable on cb reference, and you will see it affect to c2 variable as well.
cb is created in different method stack then where c1, c2 and c3 is created