2021
05-25
05-25
Java基础之Comparable与Comparator概述
自然排序Comparable对于自定义类进行排序要实现Comparable接口,重写compareTo()方法,如果不重写,像使用Arrays.sort()排序就会报错packagecom.che.lambda;importjava.util.Objects;/***@authorcheyuhangon2021/4/23*/publicclassGoodimplementsComparable{privateStringname;privateDoubleprice;publicGood(Stringname,Doubleprice){this.name=name;this.price=price;...
继续阅读 >