GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — PriorityQueue offer() Method in Java - GeeksforGeeks PriorityQueue offer() Method in JavaLast Updated : 11 Jul, 2025 The java.util.PriorityQueue.offer() method is used to insert a particular element into the Priority Queue. It acts similar to the add() method of Priority Queue.
Syntax:
Priority_Queue.offer(Object element)Parameters: The parameter element is of the type PriorityQueue and refers to the element to be inserted into the Queue. Return Value: The method returns True if the value is successfully inserted into the queue. Exceptions: The method can throw two types of exceptions:
Output:
Program 2:
Initial PriorityQueue: [4, Geeks, To, Welcome, Geeks] Priority queue after Insertion: [4, Class, Priority, Geeks, Geeks, To, The, Welcome]
Output:
Initial PriorityQueue: [5, 10, 30, 20, 15] Priority queue after Insertion: [5, 10, 30, 20, 15, 100, 120, 150] Comment Explore |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |