Method Overloading : Method Overloading « Class Definition « Java Tutorial






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.