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!