I am using a foreach loop to run through the arraylist and compare the name to a string. But I have no idea why when I compare a the name to a string it always prints out.
for (Picture item : collection) {
System.out.println("This is the label " + item.getName());
if (item.getName().equals("This shouldn't work")); {
System.out.println("Why is this working");
}
}
}
Output
getting the name test A
This is the label A
getting the name test A
Why is this working
getting the name test B
This is the label B
getting the name test B
Why is this working