void doIt() & String doIt() don't compile togather.
Hello,
i want to understand the reason why the following class won't compile and saya that the method has been duplicated.
Code:
public class A {
public void doit() {
}
public String doit() {
return "a";
}
}
I know that it would compile if the two methods had different argumets, but i want to know the reason as to why the java compiler ignores the return type. This is neither a valid overload, nor a valid override, but why does the java language skip method differentiation based on return types, and complain that the two methods above are the same.
Thanks
Gary