Online Java Compiler By
JavaTpoint.com
import java.util.ArrayDeque; import java.util.Deque; public class JavaDequegetLastExample2 { public static void main(String[] args) { Deque
deque = new ArrayDeque<>(); System.out.println("The list of the elements is given as : "); deque.add('k'); deque.add('p'); deque.add('m'); deque.add('t'); System.out.println(deque); Character val = deque.getLast(); System.out.println("The required answer : "+val); } }
Output