Update Iterator.java

changed logic