If there are two methods, they have different parameters, and their return types are different. Like this:
int test(int p) {
System.out.p
Yes, this is also an overload. Since only the name and the list of parameters are considered part of method's signature for the purposes of method overloading, both your test
methods are overloads of each other.
There may be useful scenarios for overloading a method like that, too. Consider this example:
class Sanitizer {
public static String sanitize(String s) {
...
}
public static int sanitize(int s) {
...
}
public static double sanitize(double s) {
...
}
}
A programmer who uses Sanitizer
can write things like
String s2 = Sanitizer.sanitize(s1);
int num2 = Sanitizer.sanitize(num1);
and the overload makes the code looks the same for variables of different types.