11.15

2018-04-01  本文已影响13人  Dandelion637

import java.util.*;class ExtendsObject extends Object {}public class Main {public static void main(String[] args) {Queuequeue = new PriorityQueue();

queue.offer(new ExtendsObject());

queue.offer(new ExtendsObject());

}

} /* Output:

Exception in thread "main" java.lang.ClassCastException: ExtendsObject cannot be cast to java.lang.Comparable

at java.util.PriorityQueue.siftUpComparable(Unknown Source)

at java.util.PriorityQueue.siftUp(Unknown Source)

at java.util.PriorityQueue.offer(Unknown Source)

at Main.main(Main.java:10)

*///:~

上一篇下一篇

猜你喜欢

热点阅读