I'm comparing two objects with the same attributes and values yet it's returning false
I divided the two if's conditions in order to check which one was wrong. I have debugged the algorithm so I could check if there was something wrong with my object's attribute values.
https://gyazo.com/73427a2a20558901019fc885745ca1d2
public boolean existsBag(Bag bag) {
for (int i = 0; i < this.insertedBags.length; i++) {
if (this.insertedBags[i] != null ) {
if(this.insertedBags[i].equals(bag)){
return true;
}
}
}
return false;
}
UPDATE
Problem solved by overinding the equals method in the Bag Class, thanks guys!