I thought I understood Java generics pretty well, but then I came across the following in java.lang.Enum:
class Enum>
>
This post has totally clarified to me these problem of 'recursive generic types'. I just wanted to add another case where this particular structure is necessary.
Suppose you have generic nodes in a generic graph:
public abstract class Node>
{
public void addNeighbor(T);
public void addNeighbors(Collection extends T> nodes);
public Collection getNeighbor();
}
Then you can have graphs of specialized types:
public class City extends Node
{
public void addNeighbor(City){...}
public void addNeighbors(Collection extends City> nodes){...}
public Collection getNeighbor(){...}
}