String largeNumber(final List<Integer> a)
{
List<Numbers> lstNum=convert(a);
Collections.sort(lstNum);
return null;
}
List<Numbers> convert(List<Integer> lst)
{
List<Numbers> lstNum=new ArrayList<Numbers>(lst.size());
for(int i:lst)
{
lstNum.add(new Numbers(i));
}
return lstNum;
}
我在网上有错误:
Collections.sort(lstNum);
the method sort(List<T>) in the type Collections is not applicable for the arguments (List<Numbers>)
我无法得到错误的Collections.sort()将List作为参数。为什么我会收到此错误?
这是Numbers类的代码
class Numbers implements Comparable<Integer>
{
String first=null;
Numbers(int a)
{
first=String.valueOf(a);
}
@Override
public int compareTo(Integer second) {
String one=first.concat(String.valueOf(second));
String two=String.valueOf(second).concat(first);
if(Integer.parseInt(one)>=Integer.parseInt(two))
{
return 1;
}
else
return -1;
}
}