I am trying to understand the difference between a reference data type and an object in terms of passing values. What I am struggling with is the fact that reference data types, such as a
String are actually Objects. Why is it then that if I do this...
...then String a becomes "Dog" and String B remains "Cat".
However, if I create a Cat Class with a private String speak with getter and setter methods and do this...
...then B effectively references A which means
and
both return the same value ("Meaow").
If I then set
both A & B hold the value
= "Meaow Meaow".
So the question is - Why does my own Object operate differently to a String Object (or other reference type)?
Thanks!