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