为什么我的需要实现这么多的方法??是因为jdk1.8?
package com.choosecourse; import java.util.Comparator; import java.util.function.Function; import java.util.function.ToDoubleFunction; import java.util.function.ToIntFunction; import java.util.function.ToLongFunction; public class StuComparator implements Comparator<Student> { @Override public int compare(Student arg0, Student arg1) { // TODO Auto-generated method stub return 0; } @Override public static <T, U extends Comparable<? super U>> Comparator<T> comparing( Function<? super T, ? extends U> arg0) { // TODO Auto-generated method stub return null; } @Override public static <T, U> Comparator<T> comparing( Function<? super T, ? extends U> arg0, Comparator<? super U> arg1) { // TODO Auto-generated method stub return null; } @Override public static <T> Comparator<T> comparingDouble( ToDoubleFunction<? super T> arg0) { // TODO Auto-generated method stub return null; } @Override public static <T> Comparator<T> comparingInt(ToIntFunction<? super T> arg0) { // TODO Auto-generated method stub return null; } @Override public static <T> Comparator<T> comparingLong(ToLongFunction<? super T> arg0) { // TODO Auto-generated method stub return null; } @Override public static <T extends Comparable<? super T>> Comparator<T> naturalOrder() { // TODO Auto-generated method stub return null; } @Override public static <T> Comparator<T> nullsFirst(Comparator<? super T> arg0) { // TODO Auto-generated method stub return null; } @Override public static <T> Comparator<T> nullsLast(Comparator<? super T> arg0) { // TODO Auto-generated method stub return null; } @Override public static <T extends Comparable<? super T>> Comparator<T> reverseOrder() { // TODO Auto-generated method stub return null; } @Override public Comparator<Student> reversed() { // TODO Auto-generated method stub return null; } @Override public Comparator<Student> thenComparing(Comparator<? super Student> arg0) { // TODO Auto-generated method stub return null; } @Override public <U extends Comparable<? super U>> Comparator<Student> thenComparing( Function<? super Student, ? extends U> arg0) { // TODO Auto-generated method stub return null; } @Override public <U> Comparator<Student> thenComparing( Function<? super Student, ? extends U> arg0, Comparator<? super U> arg1) { // TODO Auto-generated method stub return null; } @Override public Comparator<Student> thenComparingDouble( ToDoubleFunction<? super Student> arg0) { // TODO Auto-generated method stub return null; } @Override public Comparator<Student> thenComparingInt( ToIntFunction<? super Student> arg0) { // TODO Auto-generated method stub return null; } @Override public Comparator<Student> thenComparingLong( ToLongFunction<? super Student> arg0) { // TODO Auto-generated method stub return null; } }
compare之外的方法没有太多必要去重写。因为接口Comparator中仅有compare一个抽象方法,其余皆为普通方法。Comparator接口使用了@FunctionalInterface注解,所以才出现以上情况。
666666
你可以吧实现的方法全删了,输入一个
improt java.util.*;
那些我看不懂的东西是正则表达式么?
哈哈,你这个太6了 看上去就吓人 不晓得你点自动生成的时候是不是点岔了