Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
29 views1 page

Import Class Public Static Void: // Demonstrate Arraydeque

This document demonstrates how to use an ArrayDeque in Java like a stack. It creates an ArrayDeque of strings, pushes strings "A" through "F" onto the deque, then pops and prints each string off the deque in reverse order, demonstrating the LIFO behavior of a stack.

Uploaded by

Treymax Sikan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views1 page

Import Class Public Static Void: // Demonstrate Arraydeque

This document demonstrates how to use an ArrayDeque in Java like a stack. It creates an ArrayDeque of strings, pushes strings "A" through "F" onto the deque, then pops and prints each string off the deque in reverse order, demonstrating the LIFO behavior of a stack.

Uploaded by

Treymax Sikan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 1

// Demonstrate ArrayDeque.

import java.util.*;
class ArrayDequeDemo {
public static void main(String args[])
{
// Create an array deque.
ArrayDeque<String> adq = new
ArrayDeque<String>();
// Use an ArrayDeque like a stack.
adq.push("A");
adq.push("B");
adq.push("D");
adq.push("");
adq.push("F");
System.out.print("Popping the stack:
");
while(adq.peek() != null)
//System.out.println(adq.peek());
System.out.print(adq.pop() + " ");
System.out.println();
}
}

You might also like