Related Examples
 

Java LinkedList listIterator Example

LinkedList class listIterator method example. This example shows you how to use listIterator method.


LinkedList class listIterator method example. public ListIterator listIterator(int index) Returns a list-iterator of the elements in this list (in proper sequence), starting at the specified position in the list. Obeys the general contract of List.listIterator(int).

Here is the code

/**
 * @ # ListIterator.java
 * A class repersenting use to listIterator method of LinkedList class in java.util package
 * version 15 May 2008
 * author Rose India 
 */
import java.util.*;

public class ListIterator {

    public static void main(String args[]) {
        LinkedList list = new LinkedList();
        int i = 0;
        String str = "Rose";

        //Add the specified element to the end of this list.
        list.add(i);
        list.add(str);
        list.add("India");
        System.out.println("list = " + list);

        System.out.println("Starting at the 1st position in the list........");
        Iterator itr = list.listIterator(1);
        while (itr.hasNext()) {
            System.out.println(itr.next());
        }
    }
}

Output
list = [0, Rose, India]
Starting at the 1st position in the list........
Rose
India

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US