Method overloading means defining multiple methods with the same name but different parameter lists. Java decides which version to call based on the arguments you pass.
This is not the same as redefining a method. Each overloaded version has a unique signature because the parameter types or counts differ. The return type alone is not enough to distinguish overloaded methods.
public static int max(int a, int b) {
return (a > b) ? a : b;
}
public static double max(double a, double b) {
return (a > b) ? a : b;
}
Calling max(3, 5) runs the int version. Calling max(3.2, 5.1) runs the double version. Java picks the right one at compile time based on the argument types.