How to find the minimum value in an ArrayList, along with the index number? (Java)

前端 未结 6 1707
醉话见心
醉话见心 2020-12-02 20:05

I need to get the index value of the minimum value in my arraylist in Java. MY arraylist holds several floats, and I\'m trying to think of a way I can get the index number o

6条回答
  •  孤城傲影
    2020-12-02 20:34

    This should do it using built in functions.

    public static int minIndex (ArrayList list) {
      return list.indexOf (Collections.min(list)); }
    

提交回复
热议问题