this might seem silly, so please excuse my naivety.
If I had an integer, say int counter = 2;
then I could create integer int anotherCounter = counter;
and if I were to print the value of anotherCounter
, it would obviously return 2.
Now, if I then said anotherCounter = 5;
then this would not change the value of our first value, counter
. Likewise, if I changed the value of counter
to counter = 10;
, then that wouldn't affect anotherCounter
.
However, I've created a class that I have used to instantate some objects, but if I do what I just described to my objects, they all seem to share the same values:
HSVImage initial = new HSVImage(1920, 1080);
HSVImage duplicate = initial;
For some reason, if I now change anything in duplicate
, then it also affects intial
. Can someone explain where I've gone wrong? I assume it's to do with how I set up my HSVImage Class?
Thank you. Sam