开发者

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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜