User Story
Create a program that determines the maximum number of the following list.
List<Integer> numbers = new List<Integer>{4,3,7,12,7,1};
Code
List<Integer> numbers = new List<Integer>{4, 3, 7, 12, 7, 1};
Integer maxnum = numbers.get(0);
for(Integer i = 1; i < numbers.size(); i++) {
if(numbers.get(i) > maxnum) {
maxnum = numbers.get(i);
}
}
System.debug('The maximum of ' + maxnum);