lundi 16 mars 2015

Possibilities to short if-conditions in Java

if I want to short this if condition



if (x) {
x = false;
} else {
x = true;
}


i use the following code:



x = !x;


But what if I want to short this code? Is there a way to do that? If yes, how?



if (x) {
method_1();
} else {
method_2();
}

Aucun commentaire:

Enregistrer un commentaire