12:16 am - Thursday June 29, 2017

LinkedList Example Program for descendingIterator()

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
Author :candidjava.com
Description: It 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).
*/
import java.io.IOException;
import java.util.*;
public class LinkedListDescendingIterator
{
public static void main(String args[])
{
boolean a;
int b=60,c=20,d=30;
LinkedList l=new LinkedList();
Iterator t;
a=l.add(b);
a=l.add(c);
a=l.add(d);
t=l.descendingIterator();//it will return the elements in reverse order in a iterator
System.out.println(?The reversed  list is?);
while(t.hasNext())
{
System.out.println(t.next());
}
}
}

Output:

The reversed list is
30
20
60

Filed in: Core Java Tutorial

Comments are closed.