Java Reference
In-Depth Information
if(aValue%2!=0)
return true;
else
return false;
}
Method name
Every Java method must have a name, which must be a legal Java identifier.
Most Java programmers start method names with a lower-case character,
and then use upper-case letters for any other words in the name. This is the
case in the methods getAverage() and isOdd () listed previously.
It is a matter of good programming style to select a method name that
is consistent with the value returned by the method. The reason for this
practice is that, in Java code, the method's name identifies the value re-
turned. For example, you could name getAverage() a method that returns
the average of the elements in a numeric array. While a method that re-
turns true if the argument is an even number can be named isEven().
Parameter list
The information passed to the method is defined by the method's parame-
ter list. There is no limit to the number of elements that can be declared in
the parameter list. The format for the parameters is as follows:
DataType VariableName, DataType VariableName,...
Programmers note:
There is some confusion between the meaning of arguments and pa-
rameters in relation to methods. Arguments refer to the values passed
to the method, while parameters are the values received by the
method. Thus, we say that a method receives an int as a parameter, or
that we call the method with an int argument.
A method that receives no arguments is declared with an empty param-
eter list, as follows:
public static void eraseAll()
Search WWH ::




Custom Search