2015-04-02 102 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