Download the following classes into your java program directory: CharQueue.class and QueueException.class. Then copy/paste the following program and compile and run it:

//the program demonstrates a stack used to store characters
public class ShowQueue {
	public static void main(String [] args) {
	    // creating a new queue
		CharQueue cq = new CharQueue();
		// a variable to store stack characters
		char c;

		c = cq.dequeue();
		System.out.println("c = " + c);

		while( !cq.isEmpty()) {
		    c = cq.dequeue();
		System.out.println(); // new line

This is an example from CSci 2101 course.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.