泛型<T>出现问题。 IDEA看不到

时间:2019-10-10 13:15:59

标签: generics intellij-idea

我在使用T时遇到问题。IDEA将其打印为红色,并写上“无法解析符号'T'”。有什么问题吗?

public static class CustomizedComparator implements Comparator<T> {
        Comparator<T>[] comp;

        public CustomizedComparator(Comparator<T>... comparators) {
            comp = comparators;
        }

        @Override
        public int compare(T o1, T o2) {
            int difference = 0;
            for (Comparator<T> comparator : comp) {
                difference = comparator.compare(o1, o2);
                if (difference != 0) {
                    break;
                }
            }
            return difference;
        }
    }

0 个答案:

没有答案