您好需要有关 java 集合排序的帮助。它给了我这个错误:
Bound mismatch: The generic method sort(List<T>) of type Collections is not applicable for the arguments (List<WifiSSID>).
The inferred type WifiSSID is not a valid substitute for the bounded parameter <T extends Comparable<? super T>>
我的代码如下所示:
public class WifiSSID {
public String SSIS;
public double id;
}
public class ScanFilterWifiList {
public ScanFilterWifiList(List<WifiSSID> wifiList) {
Collections.sort(wifiList);
//Collections.sort(wifiList, new SortSSIDByid()); tried this also.
}
}
interface Comparator<WifiSSID>
{
int compare(WifiSSID obj1, WifiSSID obj2);
}
class SortSSIDByid implements Comparator<WifiSSID>
{
@Override
public int compare(WifiSSID ssid1, WifiSSID ssid2)
{
int value = 0;
if (ssid1.id > ssid2.id)
value = 1;
else if (ssid1.id < ssid2.id)
value = -1;
else if (ssid1.id == ssid2.id)
value = 0;
return value;
}
}
我做错什么了吗?