How to sort two different objects in a collection?

后端 未结 4 1971
夕颜
夕颜 2021-01-21 16:46

Suppose I have two classes CLassA and CLassB. And they have one atributte in common, for example the number of elements that each class holds.

How can i create a collect

4条回答
  •  面向向阳花
    2021-01-21 17:19

    You could make a custom java.util.Comparator and sort using the Collections.sort(List list, Comparator c) method.

提交回复
热议问题