Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.LinkedBlockingDeque; class Student { int marks; String name; public Student(int marks, String name) { this.marks = marks; this.name = name; } public String toString(){ return this.name+" got "+ this.marks +" marks."; } } public class LinkedBlockingDequePeekExample2 { public static void main(String[] args) { Student student1 = new Student(97,"Ravina"); Student student2 = new Student(87,"Jitesh"); Student student3 = new Student(77,"Ajay"); int capacity =100; LinkedBlockingDeque
deque = new LinkedBlockingDeque
(capacity); deque.add(student1); deque.add(student2); deque.add(student3); for (Student xyz : deque){ System.out.println(xyz); } System.out.println(); System.out.println("Topper of the class is "+deque.peek().name); } }
Output