I have created a method, but Java doesn't see it - Java -
i have been learning programming while thenewboston , in 80th tutorial hew writing files. followed code word word, eclipse says method undefined the type "creatfile". have checked on , on see, can't see problem. here code.
creatfile.java
import java.util.formatter; public class creatfile { private formatter x; public void openfile(){ try{ x = new formatter("chinese.txt"); } catch(exception e){ system.out.println("you have error"); } public void addrecords() { //there error on "void" , "addrecords" x.format("%s%s%s", "20 ", "jacob ", " peterson"); } public void closefile(){ //error here x.close(); } } }
apple.java (my main class)
import java.util.*; public class apples { public static void main(string[] args) { creatfile g = new creatfile() { g.openfile(); g.addrecords(); g.closefile(); } } }
your main
method doesn't make sense. try this:
public class apples { public static void main(string[] args) { creatfile g = new creatfile(); g.openfile(); g.addrecords(); g.closefile(); } }
Comments
Post a Comment