-1

Can you please point out where am I going wrong?

Works fine:

Arrays.sort(arr, (a, b) -> a[0] - b[0] );

error: array required, but Object found

PriorityQueue<int[]> pq = new PriorityQueue(10, ( (a, b) -> a[0] - b[0] ));

error: incompatible types: incompatible parameter types in lambda expression

PriorityQueue<int[]> pq = new PriorityQueue(10, ( (int[] a, int[] b) -> a[0] - b[0] ));
Arnold
  • 1
  • 1

1 Answers1

-1

The argument requires arr.length which is an int, but you are passing an arr which I assume is the array.

  • Updated question to remove ambiguity. PriorityQueue constructor: PriorityQueue(int initialCapacity, Comparator super E> comparator) – Arnold Jul 20 '21 at 03:59