Answers for "java get minimum string in Arraylist"

1

java arraylist integer min value

int minIndex = list.indexOf(Collections.min(list));
Posted by: Guest on September-15-2021
0

find minimum value in list java

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public static Integer findMin(List<Integer> list)
    {
  
        // check list is empty or not
        if (list == null || list.size() == 0) {
            return Integer.MAX_VALUE;
        }
  
        // create a new list to avoid modification 
        // in the original list
        List<Integer> sortedlist = new ArrayList<>(list);
  
        // sort list in natural order
        Collections.sort(sortedlist);
  
        // first element in the sorted list
        // would be minimum
        return sortedlist.get(0);
    }
Posted by: Guest on June-17-2021

Code answers related to "java get minimum string in Arraylist"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language