Related Examples
 

Java LinkedList class descendingIterator method example code

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


LinkedList class descendingIterator method example.public Iterator descendingIterator() Returns an iterator over the elements in this deque in reverse sequential order. The elements will be returned in order from last (tail) to first (head).

Here is the code

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

public class DescendingIterator {

    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("\nreverse sequential order of list.....");
        Iterator itr=list.descendingIterator();
        while(itr.hasNext())
            System.out.println(itr.next());
    }
}

Output
list = [0, Rose, India]

reverse sequential order of list.....
India
Rose
0

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

HOME | COPYRIGHT | CONTACT US