import java.util.ArrayList;import java.util.ListIterator;public class test {public static void main(String args[]){ ArrayList list=new ArrayList (100); for(int i=0;i<100;i++) list.add(new elem(i)); ListIterator iterator=list.listIterator(); while(iterator.hasNext()){ ((elem) iterator.next()).geti(); } try{ list.get(50).geti(); list.get(102).geti(); } catch (IndexOutOfBoundsException e) { // TODO: handle exception System.out.println("out"); } }}class elem{ private int i; elem(int i){ this.i =i; } void geti(){ System.out.println(i); } }