求求哪位大神帮帮忙,一直求不出the的个数%>_<%
程序代码:
import *; import java.util.*; public class End { private int line, charCount, countThe; private StringBuffer sb; private Vector<String> v; private Vector<StringBuffer> vsb; public End() { sb = new StringBuffer(); v = new Vector<String>(); vsb = new Vector<StringBuffer>(); } public void input() throws IOException { String s = ""; System.out.println("请输入若干行文本,以end作为结束行:"); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); s = br.readLine(); while (!s.equals("end")) { v.add(s); StringBuffer ssb = new StringBuffer(s); vsb.add(ssb); s += "\n"; line++; sb.append(s); s = br.readLine(); } } public void count() { for (int i = 0; i < v.size(); i++) { String[]s = v.get(i).split(""); String ss = ""; for (int j = 0; j < s.length; j++) { if (s[j].contains("the")) countThe++; ss+=s[j]; } charCount += ss.length(); } }//问题 public void translate() { for (int i = 0; i < vsb.size(); i++) { for (int j = 0; j < vsb.get(i).length(); j++) if (j == 0 || vsb.get(i).charAt(j - 1) == ' ') vsb.get(i).setCharAt(j, Character.toUpperCase(vsb.get(i).charAt(j))); } } public void output() { System.out.println("该文本由" + line + "行组成,字符总数为:" + charCount + ",有 " +countThe+ "个“the”"); System.out.println("将整个文本中所有单词首字母为小写的改为大写输出:"); System.out.println(vsb.toString()); } public static void main(String[] args) throws IOException { End e = new End(); e.input(); e.count(); e.translate(); e.output(); } }