Saturday 15 November 2014

Java : Collection Framework : Deque (DecendingIterator Method)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=av-fQK6fxeo&list=UUhwKlOVR041tngjerWxVccw


DequeExample.java
import java.util.Deque;
import java.util.Iterator;
import java.util.LinkedList;

/*
 *  Example of descendingIterator() method
 */
public class DequeExample
{

    public static void main(String[] args)
    {
        Deque<Integer> deque = new LinkedList<Integer>();
        deque.add(100);
        deque.add(200);
        deque.add(300);
        deque.add(400);

        System.out.println("deque : " + deque + "\n");

        /*
         * 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).
         */

        Iterator<Integer> iterator = deque.descendingIterator();

        System.out.println("Reverse Direction -- ");

        while (iterator.hasNext())
        {
            Integer value = iterator.next();
            System.out.println(value);
        }

    }

}



Output
deque : [100, 200, 300, 400]

Reverse Direction -- 
400
300
200
100


To Download DequeDemodescendingIterator Project Click the below link
https://sites.google.com/site/javaee4321/java-collections/DequeDemodescendingIterator.zip?attredirects=0&d=1

See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • No comments:

    Post a Comment