What is the difference between the add and offer methods in a queue?
- by Finbarr
Take the PriorityQueue for example http://java.sun.com/j2se/1.5.0/docs/api/java/util/PriorityQueue.html#offer(E)
According to the Collection API entry
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collection.html the add method will often seek to ensure that an element exists within the Collection rather than adding duplicates. So my question…