For a project I want to check if a String is the same as a String attribute in one of my objects.
For example, I have 3 item object:
Item spotion = new Item("small potion", 5, 0, 0, 0, 0, 0);
Item mpotion = new Item("medium potion", 20, 0, 0, 0, 0, 0);
Item lpotion = new Item("large potion", 35, 0, 0, 0, 0, 0);
I would then want to check if
String s = spotion;
would equal any of the Item's name (first attribute);
Would there be any way to do this without creating an ArrayList of items to loop through but instead just see how many items there are and loop on when created?
 
    