Java PriorityQueue poll() MethodThe poll() method of PriorityQueue class retrieves the head of this queue, and also removes it. The method returns null if this queue is empty. SyntaxParameterNA Return ValueThe poll() method returns this queue's head, and if this queue is empty returns null. Example 1Test it NowOutput: Head of queue is: Mark Queue after using poll() method : Ramesh Robert Yasir Example 2Test it NowOutput: Rima stood First in the class Vinni stood Second in the class Hinna stood Third in the class Example 3Test it NowOutput: Arnavi can visit the doctor at first. Sarita can visit the doctor after the first patient. Himani can visit the doctor after the second patient.
Next TopicJava PriorityQueue
|