Confusion in PriorityQueue
Anonymous User
46
May 16, 2020
May 16, 2020
PriorityQueue<Integer> maxHeap = new PriorityQueue<>((a,b)->b-a);
Integer[] nums1 = {10,5}; 
maxHeap.addAll(Arrays.asList(nums1));
System.out.println(maxHeap.poll());

Output. 10 // It is max item.

But when I change input to. Integer[] nums1 = {-2147483648,10};
Output is -2147483648 // But max is 10.

Anyone can help me to understand it?

Comments (1)