I am doing a school task on ArrayLists and Wrapper classes. I have to initialize a for loop, which should fill the ArrayList up with the numbers 1 to 99.
ArrayList<Integer> list = new ArrayList<Integer>();
for(int i = 1; i < 100; i++){
list.add(i);
System.out.println(list.get(i));
}
The code until the for-loop body is given in the task.
If I run the code, I get an IndexOutOfBounds Exception.
What can I modify to be able to run the loop?