|
Types of methods!
A typical method would be of following format:
return-type method-name(comma separated list of arguments)
For e.g.:
String display (String str)
Depending upon situations there may be following types of methods:
- Methods with no return type & no argument. In java, you must have a return type so in such cases return type would be void.
e.g. void display();
- Methods with no return type & one or more argument(s).
e.g. void display(String str);
- Methods with return type as well as one or more argument(s).
e.g. String display (String str);
Note: Things written above apply to most of the languages, not just Java.
In Java, method name and it's list of arguments (i.e. their type and order) is known as Method Signature. Access modifier & return type are not considered part of signature.
|