2013-10-06 70 views
-4

這裏是我的錯誤: 「異常線程‘主’了java.lang.RuntimeException:不可編譯的源代碼 - 類項目構造theController * * .theController不能被應用到給定的類型;Java的編譯錯誤,請幫幫忙,我吮吸的Java

需要:java.lang.String中

發現:整數

原因:實際參數INT不能在項目通過方法調用轉換 轉換爲java.lang.String * ** .Main.main(Main.java:23)「

我知道它告訴我問題是什麼,但我該如何解決?

這裏是我的「主」我的代碼,

public class Main { 

/** 
* @param args the command line arguments 
*/ 
public static void main(String[] args) throws IOException 
{ 


    readFile statesReadfile = new readFile(); 
    statesReadfile.loadData("States2.txt"); 
    theController statesQueues = new theController(statesReadfile.getNumStates()); 
    StatesStack myStatesStack = new StatesStack(statesReadfile.getNumStates()); 

和這裏就是我想這不會導致匹配我有一個錯誤那裏,

public class theController 
{ 
public Queues pq1; 
public Queues pq3; 
public Queues pq5; 
public Queues pq6; 
private StatesStack stateArray; 
private readFile statesReadfile; 
/* 
* 
*/ 
public theController(String filename) throws IOException 
{ 
    statesReadfile = new readFile(); 
    stateArray = statesReadfile.loadData(filename); 

    pq1 = new Queues(6); 
    pq3 = new Queues(12); 
    pq5 = new Queues(6); 
    pq6 = new Queues(12); 
    }// end of 

任何有用的建議將不勝感激,謝謝。

(噢,我有,如果需要更多的代碼)

+4

永遠不要運行沒有編譯的代碼。 –

回答

0

要傳遞到theController構造函數的參數是一個int,但它應該是一個字符串在該行theController statesQueues = new theController(statesReadfile.getNumStates());

getNumStates()回報的多少狀態。

+0

@hazerthanks我看到需要發生的事情,我只是不知道該怎麼做,每當我改變一件事情時,其他事情都會變成紅色,但是感謝任何方式的輸入。 – user1830008