public final class ImmutableList<E> { public final E head; public final ImmutableList<E> tail; public ImmutableList() { this.head = null; this.tail = null; } private ImmutableList(E head, ImmutableList<E> tail) { this.head = head; this.tail = tail; } I know that public final E head is declaring an attribute from the generic tip E , this syntax is familiar to me but what does this public final ImmutableList<E> tail; mean, why declaring this attribute using the name of the generic class and what's the difference between :
public final E head; and this :
public final ImmutableList<E> tail; are they similar ?
class A { private final A obj; }?LinkedList, which is what this code is supposed to represent I would guess.