views:

21

answers:

1

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

+1  A: 

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.

Sorantis