import java.util.*;

public class MyQueue {
	private List<Node> queue;

	MyQueue()
	{
		queue = new LinkedList<Node>();
	}

	public void add(Node n)
	{
		queue.add(n);
	}

	public void addString(String s)
	{
		Node n = new Node(s);
		add(n);
	}

	public Node remove()
	{
		Node n = queue.get(0);
		queue.remove(0);
		return n;
	}

	/**
	 * Inner class representing queue node.
	 *
	 * It's not static to show how crazy is syntax.
	 */
	public class Node {
		private String string;
		
		Node(String s)
		{
			string = s;
		}

		String value()
		{
			return string;
		}
	}

	public static void main (String [] args)
	{
		MyQueue q = new MyQueue();

		/*
		 * XXX:
		 * Using q.new is necessary because main is static function.
		 * Compare it with q.addString. addString is not static so we 
		 * can just use new without specifying context for it.
		 */
		q.add(q.new Node("1"));
		q.addString("2");

		System.out.println(q.remove().value());
		q.add(q.new Node("3"));
		q.add(q.new Node("4"));
		System.out.println(q.remove().value());
		q.add(q.new Node("5"));
		System.out.println(q.remove().value());
		System.out.println(q.remove().value());
	}
}

@@ -380,16 +380,48 @@
 *%0A%09 * It
+ really should be static, but it
 's not s
@@ -426,16 +426,21 @@
  static 
+%0A%09 * 
 to show 
@@ -458,17 +458,29 @@
 s syntax
-.
+ - see main()
 %0A%09 */%0A%09p
@@ -610,24 +610,260 @@
 ng;%0A%09%09%7D%0A%09%7D%0A%0A
+%09public class QueueIterator %7B%0A%09%09private MyQueue q;%0A%09%09public QueueIterator()%0A%09%09%7B%0A%09%09%09// Save reference of the outer class %0A%09%09%09// this iterator belongs to%0A%09%09%09q = MyQueue.this;%09%09%09%0A%09%09%7D%0A%0A%09%09public Node next()%0A%09%09%7B%0A%09%09%09return q.remove();%0A%09%09%7D%0A%09%7D%0A%0A
 %09public stat
@@ -1268,24 +1268,97 @@
 Node(%224%22));%0A
+%09%09q.add(q.new Node(%225%22));%0A%0A%09%09QueueIterator iter = q.new QueueIterator();%0A
 %09%09System.out
@@ -1362,32 +1362,33 @@
 out.println(
-q.remove
+iter.next
 ().value());
@@ -1392,34 +1392,8 @@
 ));%0A
-%09%09q.add(q.new Node(%225%22));%0A
 %09%09Sy
@@ -1405,32 +1405,33 @@
 out.println(
-q.remove
+iter.next
 ().value());
@@ -1448,32 +1448,33 @@
 out.println(
-q.remove
+iter.next
 ().value());

Add QueueIterator as an inner class.