-2
重载方法必须具有相同的返回类型(或子类型)吗? (作为压倒一切的方法)重载方法必须具有相同的返回类型(或子类型)吗?
如果是,那么为什么在以下B类方法“findmax”可以重载?
public class A {
public Integer findmax(ArrayList<Integer> list, int start){...}
}
public class B extends A {
public Float findmax(List<Integer> mylist, int start){...}
while while following one did not compile? (有没有提到的规则:重载方法不能返回原始类型)
public class A {
public Integer findmax(ArrayList<Integer> list, int start){...}
}
public class B extends A {
public float findmax(List<Integer> mylist, int start){...}
答案似乎是否定的 – tami