I came across a code snippet as below, for implementing a linked list:
public static class Element<AnyType> {
private AnyType data;
private Element<AnyType> next; // reference to the next node
Element(AnyType d, Element<AnyType> e) {
data = d;
next = e;
}
}
Can someone tell me how this is possible? How can a Java class (in my case Element) have an instance variable of its own type?