mardi 2 août 2016

If statement code break

please how can i write the below code so that it works? I have three ifs in my method, sometimes two of them are true, sometimes one of them is true, sometimes all of them are true. What can i replace in "nothing_of_above" so if none of the ifs are true the last condition will execute?

public void my_method(){

    if (x==1) {
        y++;
    }

    if (x==5) {
        y++;
    }

    if (x==10) {
        y++;
    }

    if (nothing_of_above){
        y=0;
    }

}

Aucun commentaire:

Enregistrer un commentaire