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);