java类型不匹配:无法从int转换为Comparable
我正在做一项作业,我需要添加一个控制回路。所以,在我将其添加到现有代码之前,我们将对其进行测试。我创建了一个新的java项目,并复制/粘贴了这个类。新类(TestMain)给了我一个错误:
- 类型不匹配:无法从int转换为Comparable
原始类只有一个警告,说明comparable是原始类型,应该参数化。 我读到ints不能作为可比较的,但我不明白它第一次是如何工作的
最早的课程
package testing;
public class TestMatchMain {
public static void main(String[] args) {
Comparable[] innerCollection0 = { 1, 2, 3, 4, 5 };
Comparable[] innerCollection1 = { 1, 1, 2, 5, 6, 7 };
Comparable[] innerCollection2 = { 2, 3, 5, 6, 8, 9 };
Comparable[][] collections = { innerCollection0, innerCollection1,
innerCollection2 };
TestMatch.match(collections);
}
}
给出错误的类
package test1;
public class TestMAin {
public static void main(String[] args) {
Comparable[] innerCollection0 = { 1, 2, 3, 4, 5 };
Comparable[] innerCollection1 = { 1, 1, 2, 5, 6, 7 };
Comparable[] innerCollection2 = { 2, 3, 5, 6, 8, 9 };
Comparable[][] collections = { innerCollection0, innerCollection1,
innerCollection2 };
TestMatch.match(collections);
}
}
共 (0) 个答案