public static void main(String[] args) {
PriorityQueue<Integer> queue = new PriorityQueue<>(Integer::compareTo);
for (int i = 0; i < 10; i++) {
Integer knight = (int) (Math.random() * 100);
System.out.println(knight + ",");
queue.offer(knight);
System.out.println(queue);
}
System.out.println();
System.out.println(queue);
System.out.println(queue.comparator());
}
输出结果是:[3, 10, 79, 36, 39, 92, 96, 64, 49, 97]
为什么不是按从小到大的顺序排的?