所以我试图为我的单链表类实现一个 get 方法,但我得到了错误:unreachable statement。我想知道如何解决这个问题?
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;
}