-1
public class t<T extends Number>{
private ArrayList<T> a = new ArrayList<T>();
public void add(T x){
a.add(x);
}
public T largest(){
T large = a.get(0);
int count = 1;
while(a.get(count)!=null){
if(a.get(count)>large)
large = a.get(count);
count++;
}
return large;
}
public T smallest(){
T small = a.get(0);
int count = 1;
while(a.get(count)!=null){
if(a.get(count)<small)
small = a.get(count);
count++;
}
return small;
}
}爲什麼我在我的方法中出現錯誤「二元運算符的錯誤操作數類型」?
我收到錯誤在我如果陳述我的最大和最小方法中。我在排除錯誤方面沒有運氣。請幫忙。非常感謝你。