foreach ループを使用して arraylist を実行し、名前を文字列と比較しています。しかし、名前を文字列と比較すると、常に出力される理由がわかりません。
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");
}
}
}
出力
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