get the max value from arrayList java and save it in int
List<Integer> list = new ArrayList<>(); // Creating List
list.add(3); //add elements
list.add(6);
list.add(9);
int maxNum = Collections.max(list); //save the biggest element in variable
System.out.println(max); //print 9