protected void sortHorseList(int iHorseCount)
{
int i = 0;
Horsie currentNode = head;
Horsie auxNode = new Horsie();
boolean foundChange = true;
while(foundChange)
{
foundChange = false;
for(i=0; i<iHorseCount-1; i++)
{
if (currentNode.getHorseValue() > currentNode.getNext().getHorseValue())
{
auxNode.setHorseValue(currentNode.getHorseValue());
currentNode.setHorseValue(currentNode.getNext().getHorseValue());
currentNode.getNext().setHorseValue(auxNode.getHorseValue());
foundChange = true;
}
currentNode = currentNode.getNext();
}
}
}
此代碼顯示運行主程序時,空指針錯誤。我是數據結構的新手,我希望能夠幫助你解決這個問題!請教我如何使用冒泡排序在雙向鏈表 ... HEEELP!冒泡排序的雙向鏈表 - 空指針錯誤
請用相關編程語言標記。 –
哪行引發NullPointerException? – RyPope
作業?沒有人對鏈接列表進行排序,也沒有人使用學術界以外的冒泡排序。 – EJP