So, I'm trying to compare a string to an instance variable of another class, and I can't think of a way to do this for all objects of the said class. I know for sure that if the method where this occurs is running, I have 4 objects of the class that contains the instance variable. The goal is to compare the string the user gives me, and if it is equal to the one of a previously defined object, change another instance variable in that object. In sudo-code it would be something like this:
if (colourInput == colourofAnyObjectOfTheClass)
sizeOfThatObject = sizeInput;
else
new Object(colourInput, sizeInput);
And I've previously defined what colourInput and sizeInput are. How can I go about implementing this in Java?