You could either use an else or put a return outside the if statement

·

1 min read

public int division(int n1, int n2){
        if (n2 == 0 || n1 == 0){
            return 0;
        }
        else{
            return n1 / n2;
        }
    }

or you could use that, since if the condition are met, it will not go through the second return

public int division(int n1, int n2){
        if (n2 == 0 || n1 == 0){
            return 0;
        }
        return n1 / n2;
    }