-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();
'stakeholderExperience'變量未被聲明。 – 2015-04-02 10:36:38