How do I get my substring method to work?
I keep getting a null pointer exception on this line: copy = copy.next = new Node(curr.data);
public LL substring(int startPosition) {
    if (startPosition < 0)
        throw new IndexOutOfBoundsException();
    LL substring = new LL();
    Node curr = first;
    for (int i = 0; i < startPosition; i++) {
        curr = curr.next;
    }
    Node copy = new Node(curr.data);
    substring.first = copy;
    while (curr != null && copy != null) {
        curr = curr.next;
        copy = copy.next = new Node(curr.data);
    }
    return substring;
}
 
     
    