import java.util.*;
public class ListExample {
public static void main(String[] args) {
// creating a list of integers
List < Integer > int_list = new ArrayList < Integer > ();
//adding some of the elements
int_list.add(10);
int_list.add(20);
int_list.add(30);
int_list.add(40);
int_list.add(50);
//printing the empty list
System.out.println("Element at " + 0 + " index = " + int_list.get(0));
System.out.println("Element at " + 1 + " index = " + int_list.get(1));
System.out.println("Element at " + 2 + " index = " + int_list.get(2));
System.out.println("Element at " + 3 + " index = " + int_list.get(3));
System.out.println("Element at " + 4 + " index = " + int_list.get(4));
}
};
Output
Element at 0 index = 10
Element at 1 index = 20
Element at 2 index = 30
Element at 3 index = 40
Element at 4 index = 50
Program:
Output