Added code for iterator hasNext() and next().