你们有没有看到我的代码有什么问题:
/** simulates the Josephus game by killing every other person
until the winner is the only one left.
@return The survivor of the game
*/
public E startJosephus() {
E item =head.data;
if(head.next != null){
if(head == head.previous)
return item;
}
else{
while(count>1){
removeAfter(head);
head =head.next;
}
}
return item;
}
这是我的完整代码: http: //pastebin.com/S0kWwFFV
这也是我的驱动程序类: http: //pastebin.com/Nb08Dtqk
我在这里得到了似乎源于此方法的 NullPointerExceptions。如果您发现我的代码有任何明显错误,请提供帮助。