lundi 24 août 2020

overlapping ifs refactoring of java

I'm using java8. I made the code below from the sample. I want to refactoring this, but I don't know how. Let me know if you have any good ideas.


int return = "";
if(a != "" && b != "" && c != ""){
    return 1;
}else{
    if(a != "" && b != ""){
        return 2;
    }else if(a != "" && c != ""){
        return 3;
    }else if(b != "" && c != ""){
        return 4;
    }else{
        if(a != ""){
            return 5;
        }else if(b != ""){
            return 6;
        }else if(c != ""){
            return 7;
        }else{
            return 8;
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire