As you can see, having a non void return type is important.
class TestValid {
public String f(List<String> list) {
return null;
}
public Integer f(List<Integer> list) {
return null;
}
public void test() {
f(Arrays.asList("asdf"));
f(Arrays.asList(123));
}
}
class TestInvalid {
public void f(List<String> list) {
System.out.println("strings");
}
public void f(List<Integer> list) {
System.out.println("numbers");
}
}