Here is my program...
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
ArrayList<Integer> list = new ArrayList<>();
while (true) {
int number = Integer.valueOf(scanner.nextLine());
if (number <= -1) {
break;
}
list.add(number);
}
int biggest = list.get(0);
for (int i = 0; i <= list.size()-1; i++) {
int small = list.get(i);
if (small > biggest) {
biggest = small;
}
}
System.out.println("The greatest number: " + biggest);
}
It does what the project is asking me to do. I just have to iterate through the ArrayList and print out the greatest in the list. It works! but, when I submit the project, I just get back an "Index out of bounds exception". Why does this happen?