implements vs extends in generics in Java

前端 未结 3 2088
长发绾君心
长发绾君心 2020-12-29 08:09

Can someone tell me what the differences between the first and second codes are? MaxPQ stands for priority queue, which is a collection of \"Key\" objects that can be compar

3条回答
  •  天涯浪人
    2020-12-29 08:45

    The difference is pretty straightforward: second code snippet does not compile and never will. With generics you always use extends, for both classes and interfaces. Also super keyword can be used there, but it has different semantics.

提交回复
热议问题