Class Definition Java Tutorial

It is legal to have these two methods in the same class.

public class MainClass {
  public int printNumber(int i) {
      return i*2;
  }
  public long printNumber(long i) {
      return i*3;
  }
  public static void main(String[] args) {
  }
}
printNumber(3) will invoke this method:

public int printNumber(int i)
To call the second, pass a long:

printNumber(3L);