2013-10-17 27 views
-3
public static Vehicle[] fillArray(inputString) throws exception { 
    while(readRecords.ready()) { 
     Vehicle newVehicle; 
     checkType = readRecords.readLine(); 
     if(checkType.equals("vehicle")) { 
      String ownersName = readRecords.readLine(); 
      String address = readRecords.readLine(); 
      String phone = readRecords.readLine(); 
      String email = readRecords.readline(); 
      newVehicle = new Vehicle(ownersName,address,phone,email); 
      list.add(newVehicle); 
     } 

我得到一個<identifier> expected error。信號在括號內的inputString處。爲文件聲明對象數組時標識符錯誤

有什麼建議嗎?

+2

你能告訴我們所有這些代碼嗎? 「例外」應該大寫。 – hexafraction

+0

標識符預期錯誤 – Rickie

+0

您必須爲每個輸入參數設置一個類型。在'()'的'inputString'之前放置一個類型。 – rgettman

回答

0

您應該爲參數指定一個類型。試試這個:

public static Vehicle[] fillArray(String inputString) throws exception 
1

你需要告訴參數是什麼類型:

public static Vehicle[] fillArray(String inputString) throws Exception 

否則編譯器不知道是否inputString是一個字符串,一個int,或某些其他物體。它不會被名字猜出來。