ClassName ref = new ClassName();
ref.setCredentials(Credentials);
ref.setVal(value);
ref.setUser(user);
Now when I create a new object of the same class reference, I still get the previous values I have set. Why is this so?
ClassName ref2 = new ClassName();
ref2.setVal(value);
ref2.setUser(user);
ref2.setSomethingNew(somethingNew);
My ref and ref2 instances have all the values [Credentials, Value, User and SomethingNew]. I want to differentiate these two instances. Is it because it's holding the same object?
Update My Lapse:
It's actually ref2 and not ref. I get the values in ref2 which i am not setting, and ref too holds a value which I am setting in the instance of ref2. Both are in same context.
ref.setVal(...)instead ofref2.setVal(...).ref.equals(ref2)... what does it result?Reference equalityi.e. Checkref2==refref2==refis whatObject.equalsis using that I already suggested.