Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.LinkedBlockingDeque; public class LinkedBlockingDequeOfferFirstExample2 { static int i=1; public static void main(String[] args) { int capacity=100; LinkedBlockingDeque
deque = new LinkedBlockingDeque
(capacity); deque.add("Rohit"); deque.add("Ramesh"); deque.add("Janak"); deque.add("Vishal"); deque.add("Yatin"); for (String xyz : deque){ System.out.println(i++ +". "+xyz); }int i=1; System.out.println("After adding string :"); deque.offerFirst("Yogesh"); for (String xyz : deque){ System.out.println(i++ +". "+xyz); } } }
Output