import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
public class Writer {
int n=0;
String bookName;
public void addComputerB(String name)
{
++n;
bookName = name;
try {
FileWriter filew= new FileWriter(new File("计算机类.txt"));
BufferedWriter br = new BufferedWriter(filew);
br.write(bookName);
br.newLine();
br.flush();
br.close();
filew.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public String getName(String Bname)
{
return Bname;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
addComputerB(getName("《核心技术》")); //为什么在此处提示有问题,说必须将方法改成静态的 啥原因呢?
System.out.println(n);
}
}
————————————————
版权声明:本文为CSDN博主「明明如月学长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/w605283073/article/details/46572387