New to coding and I don't understand how this if-else statement is working, as it just says "arg", but not true or false, so how does it know what to do? Shouldn't it always run if it just receives an "arg"?
I've tried if(true){winner();}, but that just makes the method winner(); run everytime, and if(false(){winner();} makes winner(); never run.
//scoreboard11.update implementation:
public void update(boolean arg){ //arg coming from display11.update() == 12
if(arg){
winner();
}
else{
turnPlayer();
}
}
//in another class
scoreboard11.update(display11.update(myX) == 12);
Using the code above, the results are correct (winner() only activates when myX = 12), but the if-else statement should always run because it is always an arg?
Aucun commentaire:
Enregistrer un commentaire