dimanche 19 juillet 2020

Multiple branches of if, else-if, else blocks executing [closed]

I had some java code setup like the following:

if (condition1) {
    //stuff
}

else if (condition2) {
    //stuff
}

else if (condition 3) {
    //stuff
}
.
.
.

else {
    //stuff
}

I was very annoyed, however, when I found out that no matter what, the else block would execute even if the actions in the if or any of the 100+ else if blocks were executed.

Aucun commentaire:

Enregistrer un commentaire