Не могли бы мы просто сделать:
Код: Выделить всё
public E getFirst() {
if (first == null) throw new NoSuchElementException();
return first.item;
}
Код: Выделить всё
public E getFirst() {
final Node f = first
if (f == null) throw new NoSuchElementException();
return f.item;
}
Подробнее здесь: https://stackoverflow.com/questions/791 ... final-node