package dk.itu.oop.lecture5; class WordIterator implements OOPIterator{ // inv: if I=N, the iterator is empty // else i points to the index if the start of the head word final String str; final int N; int i; String nextWord; WordIterator(String str){ this.str= str; i=0; N = str.length(); findNext(); } private void findNext(){ while( i0; } public String peek(){ return nextWord; } public String next(){ String ret = peek(); findNext(); return ret; } public OOPIterator cloneMe(){ try{ return super.clone(); }catch(Exception shouldNotHappen){ } } }