Online Java Compiler By
JavaTpoint.com
import java.util.ArrayDeque; import java.util.Deque; public class JavaDequepeekExample1 { public static void main(String[] args) { Deque
deque = new ArrayDeque<>(); deque.offer('J'); deque.offer('A'); deque.offer('V'); deque.offer('A'); deque.offer('T'); deque.offer('P'); deque.offer('O'); deque.offer('I'); deque.offer('N'); deque.offer('T'); Character val = deque.peek(); System.out.println("The first character is given as : "+val); System.out.println("The deque is : "); for (Character character : deque) { System.out.println(character); } } }
Output