Идея Intellij дает мне эту ошибку: «сравнить (T, T) в компараторе нельзя применить к (T, T)» для следующего код:Сравнение (T, T) в компараторе нельзя применять к (T, T)
public class LCCS<T extends Comparable<T>> {
private Comparator<T> comparator;
public LCCS(Comparator<T> comparator) {
this.comparator = comparator;
}
/**
* Loops the two given lists for finding the longest subequence
*
* @param list1 first list.
* @param list2 second list.
* @param <T> list item type.
* @return LCCS and the sublist indices of the subsequence in list1 and list2.
*/
private <T> Subsequence<T> getLongestSubsequence(List<T> list1, List<T> list2) {
Subsequence<T> output = null;
for (int indexList1 = 0; indexList1 < list1.size(); indexList1++)
for (int indexList2 = 0; indexList2 < list2.size(); indexList2++)
if (comparator.compare((T)list1.get(indexList1), (T)list2.get(indexList2)) //Here comes the error
output = inspectsubsequence(list1, list2, indexList1, indexList2, output);
return output;
}
}
Я уже изменил параметризированном тип Т и он все еще показывает мне сообщение, но вместо захвата только T. Любая помощь очень ценится.
Его только часть класса ха-ха. –