错误:无法比较()id

时间:2016-05-17 20:20:09

标签: java android

我一直在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());
        }

    });

2 个答案:

答案 0 :(得分:3)

尝试将标题转换为字符串:

return a.getTitle().toString().compareTo(b.getTitle().toString());

答案 1 :(得分:1)

更新getTitle()方法以返回String而不是CharSequence