Take the PriorityQueue for example http://java.sun.com/j2se/1.5.0/docs/api/java/util/PriorityQueue.html#offer(E)
PriorityQueue
Can anyone give me an example of a Queu
from the source code in jdk 7 as follow:
public boolean add(E e) { if (offer(e)) return true; else throw new IllegalStateException("Queue full"); }
we can easily know that the add function will return true when successfully add a new element into the queue, but throw a exception when failed .