我不知道我的主類有什麼問題。我不知道如何改變它來修復它。計算機說:從文件加載不能從靜態上下文中引用。如果我試圖改變它,我的主要課程缺失。從文件加載不能從靜態內容引用
public class Bsp3_1225814_3 {
public void static main(String [] args){
List<Linienzug> lst = new ArrayList<>();
load_from_file("C:\\Users\\schurzm\\Google Drive\\TU\\2.Semester\\VU_Grundlagen Programmieren\\Projekte_Schurz\\1225814_3\\3_in");
dump_to_file("C:\\Users\\schurzm\\Google Drive\\TU\\2.Semester\\VU_Grundlagen Programmieren\\Projekte_Schurz\\1225814_3\\3_out");
}
public void load_from_file(String file) {
Scanner s = null;
try {
s = new Scanner(
new BufferedReader(new FileReader(file))).useDelimiter("\\n");
while (s.hasNext()) {
String[] in = s.next().split(":");
Linienzug l = new Linienzug();
for (int i=0; i<(in.length-1); i++){
l.add(new Punkt(Integer.parseInt(in[i]),
Integer.parseInt(in[i+1])));
}
this.lst.add(l);
}
} catch (FileNotFoundException ex) {
System.out.print("File not found");
} finally {
if (s != null) {
s.close();
}
}
}
能否請您從您的例子刪除所有無關的代碼? –