天天看點

java運用Comparator為對象排序

要排序的類需要實作comparator接口,重寫compare方法:

user類及實作接口的内部類:

test: