ProAnswers.org

How to Overload based on the order of the arguments?

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”);
}
}
output
String: String first, int: 11
int: 99, String: Int first