Comparable and generics
When this class is created..
public static class TreeNode<E extends Comparable<E>>
开发者_运维知识库what does the <E extends Comparable<E>>
mean?
That is a generic constraint.
It means that whatever type you store in the TreeNode
must implement the Comparable<E>
interface.
It means that whenever you create an instance of this class like
TreeNode<MyClass> myTreeNode = new TreeNode<MyClass>();
MyClass must implement Comparable < MyClass >
public class MyClass implements Comparable<MyClass>
{
//CODE
}
精彩评论