2015-06-16 38 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懷疑的屬性框和它的作品。

相關問題