/**
* @author lautturi.com
* Java example: java list example
*/
import java.util.*;
public class Lautturi {
public static void main(String[] args) {
// creating an Empty Integer List
List<Integer> arr = new ArrayList<Integer>(4);
// add element to the list
// [11, 12, 13, 14]
arr.add(11);
arr.add(12);
arr.add(13);
arr.add(14);
System.out.println("List: " + arr);
// get the element at index 2
int element = arr.get(2);
System.out.println("The element at index 2 is " + element);
}
}
output:
List: [11, 12, 13, 14] The element at index 2 is 13