public void addNewLamp (Lamp newLamp)
{
for(Lamp lampName: lamps)
{
if(lampName.equals(newLamp.getLampName()))
{
System.out.println("no");
Break;
}
else
{
System.out.println("New Lamp!");
lamps.add(newLamp);
}
}
}
lamps being an array of type Lamp.
When looking at the debugger it seems like the for loop just skips everything, the entire IF statement, howcome?
EDIT: Code has been edited to fit comments, still same problem.
This is not the same question as the one that was linked to me since its more than just comparing strings, I've now changed != to "if(!lampName.getLampName().equals(newLamp.getLampName()))" and still getting the same result. Thanks for the link though