2015-06-16 41 views
0

我在分配工作,我需要添加一个控制回路。所以在我将它添加到现有代码之前要进行测试。我创建了一个新的Java项目并复制/粘贴了该类。新类(TestMain)给了我一个错误:类型不匹配:不能从int转换成可比

  • 类型不匹配:不能从int转换为可比

原班只有一个警告,指出可比性是一个原始的类型,应该被参数。 我正在阅读的内容不能作为可比对象进行投射,但我不明白第一次如何工作。

原始类是工作

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

我无法重现您的问题。你可以发布'TestMatch.match'方法的签名吗? – Pshemo

+0

他们都适合我。 – azurefrog

+0

可能你试图编译较低版本的JAVA版本 –

回答

0

增加了Java-SE-1.7库每约翰Kugelman怀疑的属性框和它的作品。

相关问题