A PriorityQueue
must order its elements somehow, either accepting a Comparator
in its constructor, or relying on its elements being Comparable
.
From PriorityQueue
javadocs:
The elements of the priority queue are ordered according to their natural ordering, or by a Comparator provided at queue construction time, depending on which constructor is used. A priority queue does not permit null elements. A priority queue relying on natural ordering also does not permit insertion of non-comparable objects (doing so may result in ClassCastException).
You haven't supplied a Comparator
, so it expects all elements added to be Comparable
, but arrays aren't Comparable
.
Supply your own Comparator<String[]>
using the PriorityQueue
constructor that takes a Comparator
.