时间: 2020-11-26|21次围观|0 条评论

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); }
}

原文链接:https://blog.csdn.net/w605283073/article/details/46572387

本站声明:网站内容来源于网络,如有侵权,请联系我们,我们将及时处理。

本博客所有文章如无特别注明均为原创。
复制或转载请以超链接形式注明转自起风了,原文地址《java方法 调用 问题
   

还没有人抢沙发呢~