java - non-static method cannot be referenced from a static context while passing between classes -
this question has answer here:
i know asked many times can't grasp of it. have method:
public static void tofile() throws filenotfoundexception{ printwriter ofile = new printwriter("output.csv"); ofile.println("tipas,vadovas,pavadinimas,produktas(mb),darbuotojai(uab)"); company com = companylist.get(companylist.size()-1); company.csv(com, ofile); ofile.close(); } on line company.csv(com, ofile); error non-static method cannot referenced static context
csv method looks this
public void csv(company com,printwriter ofile){ ofile.print("kita"); ofile.println(b+","+n+","+","+"-"+","+"-"); } as understood should have instance variables when passing think can't (am right?)
*note: company class have 2 child classes csv method. don't know if helps.
i think want change this:
company com = companylist.get(companylist.size()-1); company.csv(com, ofile); to this:
company com = companylist.get(companylist.size()-1); com.csv(ofile); and change csv method this:
public void csv(printwriter ofile){ i think correct because csv method printing out instance variables contained within com instance -- right?
Comments
Post a Comment