Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.LinkedBlockingDeque; class Employee { int wages; String name; public Employee(int wages, String name) { this.wages= wages; this.name = name; } public String toString(){ return this.name+" got "+ this.wages+" marks."; } } public class LinkedBlockingDequePollLastExample2 { public static void main(String[] args) { Employee employee1 = new Employee(12000,"Himanshu"); Employee employee2 = new Employee(4500,"Geetanjali"); Employee employee3 = new Employee(1500,"Vineet"); Employee employee4 = new Employee(1000,"Jyoti"); int capacity = 100; LinkedBlockingDeque
deque = new LinkedBlockingDeque
(capacity); deque.add(employee1); deque.add(employee2); deque.add(employee3); deque.offer(employee4); System.out.println(deque.peekLast().name+" gets the lowest wages of "+deque.pollLast().wages); System.out.println(deque.peekLast().name+" gets the second lowest wages of "+deque.pollLast().wages); } }
Output