3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by BestJewSinceJC
0

You can use LinkedList or Stack:
http://java.sun.com/j2se/1.4.2/docs/api/java/util/LinkedList.html
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Stack.html

LinkedList<String> fifo = new LinkedList<String>();
fifo.add("First");
fifo.add("Second");
fifo.add("Last");
	
System.out.println(fifo.poll());
System.out.println(fifo.poll());
System.out.println(fifo.poll());
		
Stack<String> lifo = new Stack<String>();
lifo.add("First");
lifo.add("Second");
lifo.add("Last");
		
System.out.println(lifo.pop());
System.out.println(lifo.pop());
System.out.println(lifo.pop());

gives:

First
Second
Last
Last
Second
First

Or did you want to implement one yourself?

0

A queue implementation, if you wanted to write it yourself, is simple enough that you could just start coding if you know what a queue is, so I'm thinking maybe you have a more specific question, a part of the queue implementation or a concept you don't understand?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.