title: What is the difference between the add and offer methods in a Queue in Java?
body: <p>Take the <code>PriorityQueue</code> for example <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/PriorityQueue.html#offer(E)" rel="noreferrer">http://java.sun.com/j2se/1.5.0/docs/api/java/util/PriorityQueue.html#offer(E)</a></p>
  
  <p>Can anyone give me an example of a <a href="http://docs.oracle.com/javase/8/docs/api/java/util/Queue.html" rel="noreferrer"><code>Queue</code></a> where the <a href="http://docs.oracle.com/javase/8/docs/api/java/util/Queue.html#add-E-" rel="noreferrer"><code>add</code></a> and <a href="http://docs.oracle.com/javase/8/docs/api/java/util/Queue.html#offer-E-" rel="noreferrer"><code>offer</code></a> methods are different?</p>
  
  <p>According to the <a href="http://docs.oracle.com/javase/8/docs/api/java/util/Collection.html" rel="noreferrer"><code>Collection</code></a> doc, the <code>add</code> method will often seek to ensure that an element exists within the <code>Collection</code> rather than adding duplicates. So my question is, what is the difference between the <code>add</code> and <code>offer</code> methods?</p>
  
  <p>Is it that the <code>offer</code> method will add duplicates regardless? (I doubt that it is because if a <code>Collection</code> should only have distinct elements this would circumvent that).</p>
  
  <p>EDIT:
  In a <code>PriorityQueue</code> the <code>add</code> and <code>offer</code> methods are the same method (see my answer below). Can anyone give me an example of a class where the <code>add</code> and <code>offer</code> methods are different?</p>