Dapatkan nilai maksimal dari arraylist java dan simpan di 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
Meti