you have to import the File class:import java.io.File;
new FileWriter(...) throws IOException so you have to: add a catch clause, surround with try/catch or add throws IOException to main method. This will fix also the declaration of new Scanner(f);
you are missing an } to close so this is why you have the problem with "else" function
also, when you declare the n variable inside the method, you have to initialize it.
the code can be refactored but let's focus first on solving the errors
发布评论
评论(1)
我看到的几件事:
新扫描仪(F)
的声明;Few things I see wrong:
new Scanner(f)
;