java - Load from file cannot be referenced from a static content -
i don't know what's wrong main class. dont know how change fix it. computer says: load file cannot referenced static context. if try change it, main class missing.
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(); (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"); } { if (s != null) { s.close(); } } }
you cannot call method not have static
keyword when in static method. because there implicit reference this
pointer not exist in static context.
Comments
Post a Comment