开发者

How to compare 2 objects of generic type

Is there a way to compare two objects that are generic? I'm supposed to find the largest object in a linked list. My开发者_如何学编程 first guess was to use the Object's class compareTo method, but I couldn't get that to work. Thanks


I assume that the language is Java. (since you mentioned Object and compareTo)

I suggest you to have a have a look into Comparator and Comparable interfaces.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜