我一直在compareTo
部分收到错误:
错误:(38,36)错误:找不到符号方法 的compareTo(CharSequence的)
Collections.sort(songList, new Comparator<Song>() {
public int compare(Song a, Song b) {
//this part down below
return a.getTitle().compareTo(b.getTitle());
}
});
答案 0 :(得分:3)
尝试将标题转换为字符串:
return a.getTitle().toString().compareTo(b.getTitle().toString());
答案 1 :(得分:1)
更新getTitle()
方法以返回String
而不是CharSequence
。