aspose file tools
The moose likes Java in General and the fly likes Reverse queue by using stack Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Reverse queue by using stack" Watch "Reverse queue by using stack" New topic
Author

Reverse queue by using stack

Luke Forga
Greenhorn

Joined: Jul 17, 2005
Posts: 11
Could someone help me put together a method which uses a stack to reverse the order of elements in a queue. This can be a generic method...as I will tweak it for implementation. Thanks in advance.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24040
    
  13

Like this, you mean?



[Jess in Action][AskingGoodQuestions]
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 26141
    
  66

Luke,
If this isn't for school, you could use the Stack class. It even uses generics in Java 5.0.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reverse queue by using stack
 
Similar Threads
Please help!!!
advantage stack over linked list or queue
Stack and Queue Implementation
java problem stack
Usage areas for stacks and queues