
import java.util.ArrayList;

class ArrayListTest {
	public static void main(String[] args) {

		ArrayList<Integer> list = new ArrayList<>();

		Integer first = new Integer(1);

		list.add(first);
		int second = 2;
		list.add(second);  // autoboxing

		for(Integer i : list) {
			System.out.println(i);
		}

		Integer i = list.get(0);
		System.out.println("first: " + i);

		int j = list.get(1);	// unboxing
		System.out.println("second: " + j);

		int k = list.get(2);  // throws IndexOutOfBoundsException
					// a RuntimeException
					// unchecked exception

		
					
			
	}
}
