vendredi 29 mars 2019

Simplify the complex if statements in java

Is there a way to simplyfy the below code, I can combine condition1 and condition2 but I want the else statements print different messages for each step.

if(condition1){
    if(condition2){
        if(condition3){
            //do something
        }
    }
    else{
       //sout condition2 failed
    }
}
else{
    //sout condition1 failed
}

Aucun commentaire:

Enregistrer un commentaire