I've whiteboarded this out, and cannot seem to understand why I am getting an out of memory error. The project is to create a linked list and some of its methods from scratch. My other functions are good to go, but this swap function is giving me a lot of trouble. 

When I run the debugger, the program crashes on the pj.nextNodeLink = p.nextNodeLink. The swap function is supposed to take two int inputs and swap their values. I was attempting to change the nextNodeLink pointers to do so, but clearly am failing. Any help would be much appreciated! 

```
 public void swapByIndex(int firstIndexValue, int secondIndexValue){
    if(firstIndexValue<0 || secondIndexValue<0 || firstIndexValue>size-1 || secondIndexValue>size-1) {
        throw new ArrayIndexOutOfBoundsException();
    }
    else if(head == tail){ // Case one - only one element in list
        System.out.println("The list only has one element. Nothing to swap. ");
    }
    else{ // Case Two - two or more elements
        //keep a pointer to the next element of head
        Node firstPointer = head;
        Node firstSwapElement = firstPointer;
        for(int k=0; k<firstIndexValue; k++){
            firstSwapElement = firstPointer; // save the node P is on into 'previ' node
            firstPointer = firstPointer.nextNodeLink; // P iterates to next node
        }

        Node secondPointer = head;
        Node secondSwapElement = secondPointer;
        for(int k=0; k<secondIndexValue; k++){
            secondSwapElement = secondPointer;
            secondPointer = secondPointer.nextNodeLink;
        }

        Node secondNodeSave = secondPointer; // save this so we have the correct next node link for second swap

        secondPointer.nextNodeLink = firstPointer.nextNodeLink;
        firstSwapElement.nextNodeLink = secondSwapElement;
        firstPointer.nextNodeLink = secondNodeSave.nextNodeLink;
        secondSwapElement.nextNodeLink = secondPointer;

    }
}

```