开发者

Problems with creating instance of generic type

I made a class List <K extends Comparable<K>,V> and I also have class BST<T extends com开发者_运维知识库parable<T>>

so when I do something like

private List<String, String> st = new List<String, String>();
private static BST<Integer> tree = new BST<Integer>();

those work.

but this doesnt:

private static BST<List<String,String>> tree = new BST<List<String,String>>();

complains about not being within bounds. what am i doing wrong?


BST wants T to extend Comparable, and List doesnt extend Comparable, right


The type parameter, T of class BST is expected to "extend" (actually, implement -- thank you generics!) Comparable<T>, but List doesn't satisfy that expectation.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜