Hey brauch mal wieder eure hilfe^^
kann mir einer sagen was an mein Code falsch ist^^
es soll für ein Projekt ein SelectionSort implementiert werden, das genersich arbeiten soll.
laut eclipse soll der fehler beim compare liege
fehler:
com ist vom typ (Comparator<?>)
data ist vom typ (List<?>)
Beim Debuggen werd ich auch vom compare rausgeworfen
bin so ziemlich mit meinen latein am ende erkenn da einfach kein fehler liegt vielleicht auch dadran das es so spät ist^^
kann mir einer sagen was an mein Code falsch ist^^
es soll für ein Projekt ein SelectionSort implementiert werden, das genersich arbeiten soll.
laut eclipse soll der fehler beim compare liege
fehler:
The method compare(capture#10-of ?, capture#10-of ?) in the type Comparator<capture#10-of ?> is not applicable for the arguments (Object, Object)
com ist vom typ (Comparator<?>)
data ist vom typ (List<?>)
Beim Debuggen werd ich auch vom compare rausgeworfen
bin so ziemlich mit meinen latein am ende erkenn da einfach kein fehler liegt vielleicht auch dadran das es so spät ist^^
Java:
public <T> List<T> getData() {
return (List<T>) data;
}
public Object getMax() {
Object tempObj = this.data.get(0);
if (this.com != null) {
for (Object obj : this.data) {
if (this.com.compare(obj, tempObj) > 0)
tempObj = obj;
}
} else {
for (Object obj : this.data) {
if (((Comparable<Object>) obj).compareTo(tempObj) > 0)
tempObj = obj;
}
}
return tempObj;
}
public Object getMin() {
Object tempObj = this.data.get(0);
if (this.com != null) {
for (Object obj : this.data) {
if (this.com.compare(obj, tempObj) < 0)
tempObj = obj;
}
} else {
for (Object obj : this.data) {
if (((Comparable<Object>) obj).compareTo(tempObj) < 0)
tempObj = obj;
}
}
return tempObj;
}