How do I make 2 comparable methods in only one class?

前端 未结 3 1698
借酒劲吻你
借酒劲吻你 2020-11-29 01:21

I\'ve got one class, that I sort it already by one attribute. Now I need to make another thing, that I need to create another way to sort my data. How can I make it, so I ca

3条回答
  •  Happy的楠姐
    2020-11-29 02:16

    You can only have one compareTo() method in your class.

    If you want to sort the same class more than one way, create Comparator implementations.

提交回复
热议问题