aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes ArrayDeque interface equivalent method with Queue interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "ArrayDeque interface equivalent method with Queue interface" Watch "ArrayDeque interface equivalent method with Queue interface" New topic
Author

ArrayDeque interface equivalent method with Queue interface

Kim Ming Yap
Ranch Hand

Joined: Dec 17, 2008
Posts: 53

I know that ArrayDeque offers both ends of processing (head and tail) but what i don't understand why the method offerlast() is equivalent to offer() method of Queue interface. Why not offerfirst()? Pleae advice. Thanks
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18136
    
  39

Kim Ming Yap wrote:I know that ArrayDeque offers both ends of processing (head and tail) but what i don't understand why the method offerlast() is equivalent to offer() method of Queue interface. Why not offerfirst()? Pleae advice. Thanks


Design decision. They actually had to pick one... Let's say that the designer chosed offerFirst() instead. And hence, remove is mapped to removeLast(), poll is mapped to pollLast(), etc. etc. etc.

Then I guess you can ask the same question, but instead, why isn't it offerLast()?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ArrayDeque interface equivalent method with Queue interface
 
Similar Threads
What is the Difference?
Best implementation for Queue interface.
Help in interfaces needed.
how to do collection????