Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.LinkedBlockingDeque; class Topper{ String name; int marks; public Topper(int marks,String name) { this.name = name; this.marks = marks; } public String toString(){ return name +" got "+ marks+" marks."; } } public class LinkedBlockingDequeElementExample2 { public static void main(String[] args) { Topper topper1 = new Topper(97,"Hinna"); Topper topper2 = new Topper(87,"Vinni"); Topper topper3 = new Topper(77,"Rima"); int capacity =100; LinkedBlockingDeque
deque = new LinkedBlockingDeque
(capacity); deque.add(topper1); deque.add(topper2); deque.add(topper3); for (Topper xyz : deque){ System.out.println(xyz); } System.out.println(); System.out.println("Topper of the class is "+deque.element().name); } }
Output