Java Java Objects Harnessing the Power of Objects Filling the Dispenser

1 Answer

Brendan Whiting
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brendan Whiting
Front End Web Development Techdegree Graduate 84,638 Points

If the method has a return type, you have to return something with that type, otherwise the compiler and hopefully your IDE will yell at you. So if you have a method:

public int multiply(int a, int b) {
        return a * b;
    }

I have to return an int because I said in the method signature I would return an int. Exactly what int I return is up to the use case, Java doesn't have an opinion on that.