import java.util.*;public class list {
public static void main(String[] args) {
List l = new ArrayList();
for (int i = 1; i < 6; i++) {
l.add(i);
}
Iterator it = l.iterator();
while (it.hasNext()) {
System.out.println(it.next());
}
}
}
Output :
1 2 3 4 5If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.