lundi 6 juillet 2015

Java Nested If condition

I need to have nested if condition but i see my code has the same logic for the else portion as well.

Syntax

if(condition){
    if(condition){

    }
    else{
        employee.setCompany("ABC");
        employee.setAddress("DEF");
    }
}
else{
    employee.setCompany("ABC");
    employee.setAddress("DEF");
}

Both Else portion has to execute the same logic, is there a way to avoid this and make single Else condition ?

Thanks

Aucun commentaire:

Enregistrer un commentaire