public class StringList { private LinkedList v = new LinkedList(); private Iterator iterator = new StringListIterator(); //add a new string at the end public void add(String s) { v.add(s); } //get the i-th string public String get(int i){ return (String) v.get(i); } //remove and return the i-th string public String remove(int i){ return (String)v.remove(i);} //return the number of strings in the list public int size(){return v.size(); } //return an iterator over the list public java.util.Iterator iterator() { return iterator; } //inner class class StringListIterator implements java.util.Iterator { int count = size(); public boolean hasNext() { return count > 0; } public Object next() { if (count == 0) throw new java.util.NoSuchElementException("StringList"); return v.get(--count); } public void remove() { throw new UnsupportedOperationException(); } } }