Method signatures (I)
4 March 2008In this post, I will present an interesting example related to method signature.
Method signature comprise of the following:
- method name
- return type
- input parameters
- access modifier
For example:
public Vector processText(String test, int id)
Two methods in a class can have same name provided then have different parameters. Different parameters means different no of parameters and it can also be parameters with different datatypes. For example:
public Vector processText(String test, int id) {…} public Vector processText(String test, int id, boolean valid) {…}
The example presented above is perfectly valid as even both methods have same name, but number of parameters are different.
What if we have methods with same names, same no of parameters and all the variables have same datatype but the return type is different? Interesting question. Read the next post for the answer.
Related Posts:
Top Of Page | Trackback
If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.
It will look like this: Method signatures (I)