Hi Everyone,
I'm new here and also new in using Java.
I want to make an iterator without using the default methods hasNext, hasPrevious.
Here is what I've already done using the default methods:
import java.util.*;
public class HomeIterator{
public static void main(String[] args) {
int i = 0;
ArrayList list_a = new ArrayList();
list_a.add("bicycle");
list_a.add("trycycle");
list_a.add("quadrcycle");
list_a.add("pentacycle");
list_a.add("hexacycle");
ListIterator it = list_a.listIterator();
while (it.hasNext()){
i++;
Object element_list_a = it.next();
System.out.println("Element no"+" "+i+":"+" "+element_list_a);
}
System.out.println();
i++;
while (it.hasPrevious()){
i--;
Object element_lista_inv = it.previous();
System.out.println("Element no"+" "+i+":"+" "+element_lista_inv);
}
}
}
So, I would like to do something similar to this, just without using the default hasNext, hasPrevious.