您好,我對Java非常陌生,並且在構建DoublyLinkedList時遇到了這個問題。運行測試程序時出現此錯誤。任何人都可以建議我的代碼修復?任何幫助是極大的讚賞! 錯誤消息: 異常在線程 「主要」 java.lang.ClassCastException:hw3.Deque $節點不能轉換爲java.lang.Integer中Java ClassCastException
@SuppressWarnings("unchecked")
public E removeFirst(){ // delete and return the item at the front
Node temp=head;
if (isEmpty()){ throw new NoSuchElementException(); }
else{
if(head.next==null){
head=null;
tail=null;
}else{
head=head.next;
head.prev=null;
}
return (E) head;
}
}
請[閱讀](http://stackoverflow.com/help/mcve)瞭解如何創建**最小,完整且可驗證的**示例。 – Docteur