So I'm trying to implement a get method for my singly linked list class and I get the error: unreachable statement. I was wondering how can I fix this?
public T get(int i) {
// TODO: Implement this
Node u = head;
for(int j = 0; j < i; j++){
u = u.next;
}
return u.x;
if (i < 0 || i > n - 1) throw new IndexOutOfBoundsException();
return null;
}