import java.util.*; public class MyList { public static void main(String[] args) { LinkedList list = new LinkedList(); list.add(new Integer(1)); list.add(new Integer(2)); list.add(new Integer(3)); list.add(new Integer(4)); for ( Iterator it = list.iterator(); it.hasNext(); ) System.out.print(it.next()+" "); list.remove(new Integer(2)); System.out.println(); for ( Iterator it = list.iterator(); it.hasNext(); ) System.out.print(it.next()+" "); System.out.println(); } }