foreach循环完全忽略我的if语句。for循环忽略布尔如果语句
for(InfoBox infoBox : mAbilities)
{
if(infoBox.CheckPressed(event));
{
//This is being outputted each time, even if the if statement returns false.
System.out.println(infoBox.getName());
}
System.out.println(infoBox.CheckPressed(event));
System.out.println(infoBox.getName());
}
这就是为什么你应该尊重[Java Code Conventions](http://www.oracle.com/technetwork/java/javase/documentation/codeconvtoc-136057.html),并将左括号放在同一行,如/ if等。 – Xaerxess
您有一个“系统.out.println(infoBox.getName());”在{}之外的if {}之外。你确定这不是你看到的印刷品吗?... – TheCodeArtist