After research on Object fields, all I have found is that they get stored in that other Class.
But let's say that I'm storing a Class called Inventory on a field at Class A.
private Inventory userInventory;
That Inventory Object has the criminal record, stored in a hashmap of Crime and Date.
private HashMap<Crime, Calendar> record;
That map is changed within the Inventory like so:
public void addCrime(Crime crime, Calendar instance) {
record.put(crime, instance);
}
My question is, the stored Inventory in the Class A's field will still be the same if I execute addCrime on it?
Yes,Inventory object will be the same,meaning the reference will be the same as before.but its reference object's attr named record
will add a new pair.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments