2015-04-02 75 views
-1

我有這樣的代碼正在做我的頭,我在編譯時繼續收到以下錯誤。有任何想法嗎?Java「找不到符號」

8 errors found: 
File: /Users//Desktop/Migration/BookingGUI.java [line: 573] 
Error: /Users//Desktop/Migration/BookingGUI.java:573: cannot find symbol 
symbol : variable stakeholderExperience 
location: class BookingGUI 
File: /Users//Desktop/Migration/BookingGUI.java [line: 576] 
Error: /Users//Desktop/Migration/BookingGUI.java:576: cannot find symbol 
symbol : variable stakeholderExpertise 
location: class BookingGUI 

整個代碼是相當大的,所以我不想張貼整個事情......基本上我試圖讓這件事情一旦被打開,從文本文件加載數據。

while(sc.hasNextLine()) { 
 
       str = sc.nextLine(); 
 
       // split line into parts by tab 
 
       parts = str.split("\t"); 
 
       // if all details of stakeholder are present 
 
       if(parts.length == 6) { 
 
        // get all details from parts string arrray of stakeholder 
 
        phone = Integer.parseInt(parts[0]); 
 
        stakeholderName = parts[1]; 
 
        stakeholderFamily = parts[2]; 
 
        stakeholderEmail = parts[3]; 
 
        stakeholder = null; 
 
        // if part of 4 string is not a dash then it is a 
 
        // stakeholder 
 
        if(parts[5] != "-") { 
 
         stakeholderProjectName = parts[5]; 
 
         stakeholder = new Client(phone, stakeholderName, 
 
          stakeholderFamily, stakeholderEmail, 
 
          stakeholderIndustry, stakeholderProjectName); 
 
        // else if part 5 is not a dash then it is a classical 
 
        // stakeholder 
 
        } else if(parts[6] != "-") { 
 
         stakeholderExperience = parts[6]; 
 
         stakeholder = new Developer(phone, stakeholderName, 
 
          stakeholderFamily, stakeholderEmail, 
 
          stakeholderExpertise, stakeholderExperience); 
 
        // else it is a general stakeholder 
 
        } else { 
 
         stakeholder = new Stakeholder(phone, stakeholderName, 
 
          stakeholderFamily, stakeholderEmail); 
 
        } 
 
        // add stakeholder to stakeholders model and also to stakeholders in 
 
        // teams panel 
 
        stakeholderMdl.addElement(stakeholder); 
 
        stakeholderTeamMdl.addElement(stakeholder); 
 
       } 
 
      } 
 
      sc.close();

+1

'stakeholderExperience'變量未被聲明。 – 2015-04-02 10:36:38

回答

0

/BookingGUI.java:573:找不到符號 符號:可變stakeholderExperience 位置:當編譯器找不到一個標識符這種類型的錯誤發生類BookingGUI

。在這種情況下,它無法找到變量stakeholderExperience變量。你有沒有在你的BookingGUI類中的任何地方聲明它?

+0

現貨,只需要新的眼睛:)謝謝 – EMJ 2015-04-02 11:06:44