Implemented the infinitive loop with class which implements Iterable<T>