June 2018
Beginner
722 pages
18h 47m
English
A Java method is a group of statements that are always executed together with the purpose of producing a certain result in response to a certain input. A method has a name, either a set of input parameters or no parameters at all, a body inside {} brackets, and a return type or void keyword that indicates that message does not return any value. Here is an example of a method:
int multiplyByTwo(int i){ int j = i * 2; return j;}
In the preceding code snippet, the method name is multiplyByTwo. It has one input parameter of type int. The method name and the list of parameter types are together called method signature. The number of input parameters is called arity. Two methods have the same signature if they have the same name, the ...
Read now
Unlock full access