Removing overloaded method in Java
问题 There are 2 overloaded methods. Each of these methods converts a list of one type to a list of a different type. But the first method uses a comparator. class SomeClass { public static <T, G> List<G> toListOfNewType(List<T> inputList, Function<T, G> mapperFunction, Comparator<? super G> comparator) { return Stream.ofNullable(inputList) .flatMap(List::stream) .map(mapperFunction) .sorted(comparator) .collect(Collectors.toList()); } public static <T, G> List<G> toListOfNewType(List<T> inputList