Linked List 内のすべてのトークンを 1 ポジション左にシフトする必要があります。
メソッドのコードは次のとおりです。
private LLNode<E> head; // the first node in the list
private LLNode<E> tail; // the last node in the list
public void shiftLeft()
{
LLNode<E> temp = new LLNode<E>();
temp = head;
head = head.next;
tail.next = temp;
}
/*from main method
TopSpinLinkedList<Integer> ll = new TopSpinLinkedList<Integer>(numTokens, spinSize);
//fills LinkedList with tokens
for(int i = 1; i <= numTokens; i++) {
ll.add(i);
}
*/
メソッドを呼び出すと、実行時に nullpointer エラーが表示されます。どんな助けでも大歓迎です。ありがとう。