我得到一個「無法從靜態上下文中引用的非靜態方法」 - 我相信這基本上意味着該對象沒有被創建。我究竟做錯了什麼?Java解析csv並創建對象
public void loadData() {
String csvFile = "/data/patientList.csv";
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(csvFile));
br.readLine();
String line1 = null;
while ((line1 = br.readLine()) != null) {
String[] patient = line1.split(",");
int bedNum = Integer.parseInt(patient[0]);
Patient patient1 = new Patient(bedNum, patient[1], patient[2], patient[3], patient[4],
RESPIRATORY_RATE, HEART_RATE, SYSTOLIC, SPO2);
這裏拋出錯誤,例如:
patientNameField.setText(Patient.getFistName());
哪行有錯誤:
如下更改您的密碼?問題中的錯誤意味着您正在從靜態函數內調用成員函數(沒有「this」可用)。但是我無法從您發佈問題的代碼中知道。沒有足夠的信息。 – jwismar 2014-10-29 23:27:15
無論我嘗試使用Patient類對象,我都會收到錯誤消息。哪些信息會有幫助? – ClaaziX 2014-10-29 23:44:46