Java PriorityQueue comparator() MethodThe comparator() method of PriorityQueue() class returns the comparator that is used to order the elements of this queue, or returns null if the elements of this queue are sorted according to natural ordering. SyntaxReturn ValueThe comparator() method returns the comparator that is used to order this queue, or returns null if this queue is sorted according to natural ordering. Example 1Test it NowOutput: Comparator value is = null Example 2Test it NowOutput: Ram got 98 marks. Rahul got 19 marks. Himanshu got 78 marks. Geetanjali got 18 marks. Comparator value is [email protected]
Next TopicJava PriorityQueue
|