Example usage for java.util ListIterator hasNext

List of usage examples for java.util ListIterator hasNext

Introduction

In this page you can find the example usage for java.util ListIterator hasNext.

Prototype

boolean hasNext();

Source Link

Document

Returns true if this list iterator has more elements when traversing the list in the forward direction.

Usage

From source file:Main.java

public static void main(String[] a) {
    List<String> list = new LinkedList<String>();
    list.add("A");
    list.add("B");
    list.add("C");
    list.add("D");

    ListIterator iter = list.listIterator();
    while (iter.hasNext()) {
        System.out.println(iter.next());
    }//from  w  ww .  jav  a  2  s  .  c  o m

}

From source file:Main.java

public static void main(String[] a) {
    List<String> list = new LinkedList<String>();
    list.add("A");
    list.add("B");
    list.add("C");
    list.add("D");

    ListIterator iter = list.listIterator(1);
    while (iter.hasNext()) {
        System.out.println(iter.next());
    }/* w  ww .ja va 2  s . co m*/

}

From source file:Main.java

public static void main(String[] a) {

    List list = new LinkedList();
    list.add("A");
    list.add("B");
    list.add("C");
    list.add("D");

    ListIterator iter = list.listIterator();
    while (iter.hasNext()) {
        System.out.println(iter.next());
    }/*  ww  w.  ja  v a  2  s.  c  o m*/

}

From source file:Main.java

public static void main(String[] args) {
    Vector<String> v = new Vector<String>();

    v.add("1");// w ww . j a v a  2s  .com
    v.add("2");
    v.add("3");
    v.add("4");
    v.add("5");

    ListIterator itr = v.listIterator();
    while (itr.hasNext()) {
        System.out.println(itr.next());
    }
    while (itr.hasPrevious()) {
        System.out.println(itr.previous());
    }
}

From source file:Main.java

public static void main(String[] args) {
    ArrayList<String> aList = new ArrayList<String>();
    aList.add("1");
    aList.add("2");
    aList.add("3");
    aList.add("4");
    aList.add("5");

    ListIterator listIterator = aList.listIterator();
    while (listIterator.hasNext()) {
        System.out.println(listIterator.next());
    }/*from ww  w  .ja va 2  s  .  c o m*/
}

From source file:Main.java

public static void main(String[] args) {
    ArrayList<String> aList = new ArrayList<String>();
    aList.add("1");
    aList.add("2");
    aList.add("3");
    aList.add("4");
    aList.add("java2s.com");

    ListIterator listIterator = aList.listIterator();
    while (listIterator.hasNext()) {
        System.out.println(listIterator.next());
    }// ww w  . j ava2  s . c  o  m
}

From source file:Main.java

public static void main(String[] args) {
    Vector<Integer> vec = new Vector<Integer>();

    vec.add(4);/*from ww w. j  a  v  a 2 s .  com*/
    vec.add(3);
    vec.add(2);
    vec.add(1);

    System.out.println(vec);

    ListIterator<Integer> it = vec.listIterator(2);
    while (it.hasNext()) {
        System.out.println(it.next());
    }
}

From source file:UtilDemo3.java

public static void main(String[] args) {
    String[] coins = { "A", "B", "C", "D", "E" };

    List l = new ArrayList();
    for (int i = 0; i < coins.length; i++)
        l.add(coins[i]);/* w w  w  .j a v a 2 s .  com*/

    ListIterator liter = l.listIterator();

    while (liter.hasNext())
        System.out.println(liter.next());

    Collections.reverse(l);

    liter = l.listIterator();

    while (liter.hasNext())
        System.out.println(liter.next());
}

From source file:Main.java

public static void main(String[] args) {
    String[] coins = { "A", "B", "C", "D", "E" };

    List src = new LinkedList();
    for (int i = 0; i < coins.length; i++)
        src.add(coins[i]);//from  ww w .j  a  v a  2s  . co m

    List dst = new ArrayList();
    for (int i = 0; i < coins.length; i++)
        dst.add("");

    Collections.copy(dst, src);

    ListIterator liter = dst.listIterator();

    while (liter.hasNext())
        System.out.println(liter.next());
}

From source file:Main.java

public static void main(String[] args) {
    ArrayList<String> aList = new ArrayList<String>();
    aList.add("1");
    aList.add("2");
    aList.add("3");
    aList.add("4");
    aList.add("5");

    ListIterator<String> listIterator = aList.listIterator();

    while (listIterator.hasNext()) {
        System.out.println(listIterator.next());
    }//from w  w  w  . j  a  v  a  2  s.c om
    while (listIterator.hasPrevious()) {
        System.out.println(listIterator.previous());
    }
}