Online Java Compiler By
JavaTpoint.com
import java.util.Iterator; import java.util.concurrent.LinkedBlockingDeque; public class LinkedBlockingDequeDescendingIteratorExample3 { static int i=1; public static void main(String[] args) { LinkedBlockingDeque
deque = new LinkedBlockingDeque
(); Student student1 = new Student("15cs1029", "MVN University", "Reema"); Student student2 = new Student("15cs1010", "MVN University", "Geetanjali"); Student student3 = new Student("17cs1029", "MR University", "Vineet"); deque.add(student1); deque.add(student2); deque.add(student3); Iterator
iterator = deque.descendingIterator(); //Returns a descending iterator over the elements while (iterator.hasNext()) { System.out.println(i++ + "." + iterator.next()); } } } class Student { static int i = 1; public String name; public String college; String rollNo; Student(String rollNo, String college, String name) { this.rollNo = rollNo; this.name = name; this.college = college; } public String toString() { return ".Roll No. = " + this.rollNo + "\n College = " + this.college + "\n Name = " + this.name + "\n"; } }
Output