1import java.util.ArrayList;
2import java.util.Collections;
3import java.util.List;
4
5public static Integer findMin(List<Integer> list)
6 {
7
8 // check list is empty or not
9 if (list == null || list.size() == 0) {
10 return Integer.MAX_VALUE;
11 }
12
13 // create a new list to avoid modification
14 // in the original list
15 List<Integer> sortedlist = new ArrayList<>(list);
16
17 // sort list in natural order
18 Collections.sort(sortedlist);
19
20 // first element in the sorted list
21 // would be minimum
22 return sortedlist.get(0);
23 }