Java PriorityQueue.offer(E e)
Syntax
PriorityQueue.offer(E e) has the following syntax.
public boolean offer(E e)
Example
In the following code shows how to use PriorityQueue.offer(E e) method.
/* www . j av a 2 s . c om*/
import java.util.PriorityQueue;
public class Main {
public static void main(String args[]) {
PriorityQueue<Integer> prq = new PriorityQueue<Integer>();
for ( int i = 0; i < 10; i++ ){
prq.add (i) ;
}
System.out.println(prq);
// add using offer() function call
prq.offer(122);
System.out.println(prq);
}
}
The code above generates the following result.
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »