Method Overloading : Method Overloading « Class Definition « Java Tutorial

Java Tutorial
1. Language
2. Data Type
3. Operators
4. Statement Control
5. Class Definition
6. Development
7. Reflection
8. Regular Expressions
9. Collections
10. Thread
11. File
12. Generics
13. I18N
14. Swing
15. Swing Event
16. 2D Graphics
17. SWT
18. SWT 2D Graphics
19. Network
20. Database
21. JSP
22. JSTL
23. Servlet
24. Web Services SOA
25. Email
26. J2ME
27. J2EE Application
28. XML
29. Design Pattern
30. Log
31. Security
32. Apache Common
Java
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Tutorial » Class Definition » Method Overloading 
5. 5. 1. Method Overloading

Java allows you to have multiple methods having the same name, as long as each method accept different sets of argument types. In other words, in our example, it is legal to have these two methods in the same class.

public String printString(String string)
public String printString(String string, int offset)

This technique is called method overloading. The return value of the method is not taken into consideration. As such, these two methods must not exist in the same class:

public int countRows(int number);
public String countRows(int number);
5. 5. Method Overloading
5. 5. 1. Method Overloading
5. 5. 2. Using Method Overloading
5. 5. 3. Pass long parameters to overloading method
5. 5. 4. Primitives and overloading
5. 5. 5. Overloading based on the order of the arguments
5. 5. 6. Demonstration of both constructor and ordinary method overloading
5. 5. 7. Using overloaded methods to print array of different types
5. 5. 8. Methods with differing type signatures are overloaded - not overridden.
w_w_w___._j_a___v__a__2__s__.___c_o_m__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.