Arrays.asList() of an array

后端 未结 9 831
我寻月下人不归
我寻月下人不归 2020-11-27 15:41

What is wrong with this conversion?

public int getTheNumber(int[] factors) {
    ArrayList f = new ArrayList(Arrays.asList(factors));  
    Co         


        
9条回答
  •  南笙
    南笙 (楼主)
    2020-11-27 16:30

    this is from Java API "sort

    public static void sort(List list) Sorts the specified list into ascending order, according to the natural ordering of its elements. All elements in the list must implement the Comparable interface. Furthermore, all elements in the list must be mutually comparable (that is, e1.compareTo(e2) must not throw a ClassCastException for any elements e1 and e2 in the list)."

    it has to do with implementing the Comparable interface

提交回复
热议问题