java.lang.NoSuchMethodError: No interface method sort(Ljava/util/Comparator;) exception in sorting arraylist android

前端 未结 5 1274
青春惊慌失措
青春惊慌失措 2020-12-09 16:16

I\'m trying to sort an ArrayList in Java in Android app but I\'m getting this weird exception.

Code:

eventsList.sort(new Comparator<         


        
5条回答
  •  不知归路
    2020-12-09 16:30

    List doesn't have its own sorting method, you'll need to call

    Collections.sort() 
    

    as the method on the list. If this returns a ClassCastError, that means the list has non-sortable items. I think this should fix it, but without full code, it's hard to check.

提交回复
热议问题