【发布时间】:2026-02-16 12:25:01
【问题描述】:
如果给我这个方法头:
/**
* This generic method sorts the input array using an insertion sort and the input Comparator object.
*/
public static <T> void insertionSort(T[] array , Comparator<? super T> comparatorObj){
// Implement method
}
对于参数中的Comparator<? super T> comparatorObj 部分,我是否想制作一个比较器对象方法,告诉它在insertionSort 参数中使用时应该如何比较?
【问题讨论】:
标签: java generics comparator superclass insertion-sort