import java.util.*;
import javax.swing.JOptionPane;

public class Planets2{
  public static String print(Collection c)
  {
    String s="";
    Iterator i=c.iterator();
    while(i.hasNext()) {s+=i.next()+"\n";}
    return s;
  }
  
  public static void main (String args[]) {
    String names[] = {"Mercur", "Venus", "Earth",
    "Mars", "Jupiter", "Saturn", "Uranus",
    "Neptun", "Pluto"};
    ArrayDeque<String> Planets = new ArrayDeque<String> ();
    for(int i=0;i<names.length;i++) 
    { Planets.add(names[i]);}
    String ss="Complete list : \n"+print(Planets);
    JOptionPane.showMessageDialog(null,ss);
    Planets.removeFirst();
    ss="One element removed :\n"+print(Planets);
    JOptionPane.showMessageDialog(null,ss);
    Planets.removeFirst();
    ss="One element removed :\n"+print(Planets);
    JOptionPane.showMessageDialog(null,ss);
  }
}
