The foreach loop is completely ignoring my if statement.
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());
}
You've prematurely terminated your if statement with a semicolon:
if(infoBox.CheckPressed(event)); // <-- remove the semicolon
This makes the following block a freestanding block that will always execute.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With