Online Java Compiler By
JavaTpoint.com
import java.util.ArrayDeque; import java.util.Deque; public class JavaDequepopExample1 { public static void main(String[] args) { Deque<String> deque = new ArrayDeque<>(); deque.offer("Apple"); deque.offer("Guava"); deque.offer("Mango"); deque.offer("Pear"); String val = deque.pop(); System.out.println("The first fruit which has been removed is : "+val); System.out.println("The final deque is given as : "); for (String string : deque) { System.out.println(string); } } }
Output