Return type

The program can therefore rely on the method returning a value of type int.

Any method declared void doesn't return a value.

In such a case, a return statement can be used to branch out of a control flow block and exit the method and is simply used like this: If you try to return a value from a method that is declared void, you will get a compiler error.

The getArea() method in the Rectangle Rectangle class that was discussed in the sections on objects returns an integer: This method returns the integer that the expression width * height evaluates to.

The getArea method returns a primitive type.