JCreator编译时显示 错误:进行语法分析时已到达文件结尾,高手帮忙看看怎么回事 10
importjava.io.*;publicclassStringDemo{publicstaticvoidmain(Stringargs[])throwsIOExcep...
import java.io.*;
public class StringDemo {
public static void main(String args[]) throws IOException{
String word=new String("java");
String text="";
int total=0;
String tempStr="";
System.out.println("请输入文本,输入\"end\"结束");
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
while(!(tempStr=in.readLine()).equalsIgnoreCase("end")){
text+=tempStr;
}
int i=0;
while(i<=text.length()-4){
if(text.charAt(i)=='j'||text.charAt(i)=='j'){
String subStr=text.substring(i,i+4);
if(subStr.equalsIgnoreCase(word)){
total++;
i=i+4;
}
else i++;
}
System.out.println("输入的文本中共包含java单词"+total+"个");
}
} 展开
public class StringDemo {
public static void main(String args[]) throws IOException{
String word=new String("java");
String text="";
int total=0;
String tempStr="";
System.out.println("请输入文本,输入\"end\"结束");
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
while(!(tempStr=in.readLine()).equalsIgnoreCase("end")){
text+=tempStr;
}
int i=0;
while(i<=text.length()-4){
if(text.charAt(i)=='j'||text.charAt(i)=='j'){
String subStr=text.substring(i,i+4);
if(subStr.equalsIgnoreCase(word)){
total++;
i=i+4;
}
else i++;
}
System.out.println("输入的文本中共包含java单词"+total+"个");
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询