Home  >  Q&A  >  body text

java-se - Java TreeSet的比较器排序的疑问?

PHP中文网PHP中文网2741 days ago720

reply all(1)I'll reply

  • 怪我咯

    怪我咯2017-04-18 10:52:51

    You need to write the class you marked and rewrite the compareTo() method in it. What is implemented in the method is the comparison method you need. For example, if you want to compare based on students' names, you can just write the comparison method of the names in it. You can see how its default comparison method is implemented and you will understand. There is no change in the creation of collection objects.

    reply
    0
  • Cancelreply