I am trying to understand the following line which initiates a Priority Queue:
PriorityQueue<int[]> pq = new PriorityQueue<>((a, b) -> b[1] - a[1]);
Comparing with Constructor section in the document, https://docs.oracle.com/javase/7/docs/api/java/util/PriorityQueue.html
I couldn't figure out which Constructor it uses. Could someone please share the thought?
Also, is there a document that could better explain/define syntax (a, b) -> b[1] - a[1] ... though I could guess what it means.
Thanks a lot!
Comparatoris being supplied to the queue so that items are added in the correct order. The Java 8PriorityQueueimplementation allows that form of the constructor.->, it requires at least Java 1.8 to compile!