- Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathAnimalIterator.java
More file actions
Latest commit
42 lines (35 loc) · 809 Bytes
/
Copy pathAnimalIterator.java
File metadata and controls
42 lines (35 loc) · 809 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
packagecustomiterator;
importjava.util.ArrayList;
importjava.util.Iterator;
importjava.util.List;
/**
* Custom Iterator.
* User: rpanjrath
* Date: 9/12/13
* Time: 1:32 PM
*/
publicclassAnimalIteratorimplementsIterator {
List<?> animalList = newArrayList();
privatestaticintposition;
publicAnimalIterator(Animalanimal) {
this.animalList = animal.getAnimal();
}
@Override
publicbooleanhasNext() {
if (position < animalList.size()) {
returntrue;
} else {
returnfalse;
}
}
@Override
publicObjectnext() {
Objectobject = animalList.get(position);
position++;
returnobject;
}
@Override
publicvoidremove() {
animalList.remove(position);
}
}