Inserts the specified element into this priority queue. As PriorityQueue is not a capacity-restricted queue, this method always returns true.
PriorityQueue does not allow null elements:

package com.logicbig.example.priorityqueue;
import java.util.PriorityQueue;
public class OfferExample2 {
public static void main(String... args) {
PriorityQueue<String> pq = new PriorityQueue<>();
pq.offer(null);
}
}
Output
java.lang.NullPointerException
at java.util.PriorityQueue.offer (PriorityQueue.java:336)
at com.logicbig.example.priorityqueue.OfferExample2.main (OfferExample2.java:15)