import java.util.*;
class ArrayListDemo2
{
public static void main(String args[])
{
ArrayList al=new ArrayList();
al.add("one");
al.add("two");
al.add("three");
al.add("four");
for(int i=0;i<al.size();i++)
{
System.out.println(al.remove(i));
}
}
}
Expected Output:-
one
two
three
four
But I got
one
three
What is the reason for this output?
How to get my expected output?