vendredi 13 juillet 2018

operators ? and : with boolean and void [duplicate]

This question already has an answer here:

I am trying to figure out how to use operators ? : instead if else block

My case is below:

if (boolean variable) {
void1(); }
else {
void2();
}

is it possible to do this by that way:

boolean variable ? void1() : void2();

I was looking for an answer but I cannot find it with boolean and call void method

Aucun commentaire:

Enregistrer un commentaire