Home > AI > Language > Java > ArrayQueue >

peekLast

Example:


public class Test {
    public static void main(String args[])
    {

        Deque<String> q = new ArrayDeque<>();

        q.add("Welcome");
        q.add("To");
        q.add("jobyme88");

        System.out.println("Initial ArrayDeque: " + q);

        // Displaying the last element
        System.out.println("The last element is: " + q.peekLast());

        System.out.println("Final ArrayDeque: " + q);
    }
}
Related posts:

Leave a Reply