How to sort an arraylist of objects java?

后端 未结 6 1068
失恋的感觉
失恋的感觉 2020-12-10 16:26

So I want an arraylist of objects in java.

I have object1.number and object2.number, object3.number, etc... but those objects

6条回答
  •  北海茫月
    2020-12-10 17:27

    Use to Collections.sort() to sort an ArrayList in Java 8:

    Collections.sort(array, new Comparator() {
        @Override
        public int compare(Class o1, Class o2) {
            //compare object properties
        }
    });
    

提交回复
热议问题