Methods have many other attributes such as parameters, access control, and so on. Returning a Value from a Method Java requires that a method declare the data type of the value that it returns. If a method returns no value, it can be declared to return void . Complex types are comprised of multiple or complex values and, sometimes, the operations that can be performed on those values. Complex types include classes, interfaces, and arrays.
Methods can return either values of simple data types or of complex data types.
The return operator returns the value and must be the last statement in the method. Any method that is not declared void must contain a return statement. The return operator places the indicated value on the stack where the calling method can then retrieve it. The data type of the value returned by the return statement must match the data type that the method claims to return. For example, you can't return an Object from a method declared to return an integer.