Overloading based on the order of the arguments : Method Overloading « Class Definition « Java Tutorial






public class MainClass {
  static void print(String s, int i) {
    System.out.println("String: " + s + ", int: " + i);
  }

  static void print(int i, String s) {
    System.out.println("int: " + i + ", String: " + s);
  }

  public static void main(String[] args) {
    print("String first", 11);
    print(99, "Int first");
  }
}
String: String first, int: 11
int: 99, String: Int first








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.