import java.io.*;
public class Search1
{
public static void main(String args[])
{
int count=0,first=0,second=0;
String text="ab cd ef g";
String s="";
String subtext=text;
System.out.println(text);
System.out.println("请输入你要查找的字符串:");
try
{
BufferedReader in=new BufferedReader(new InputStreamReader (System.in));
s=in.readLine();
}
catch(IOException e){}
for(int i=1;i<=text.length();i+=second+1)
{
second=subtext.indexOf("");
String temp=subtext.substring(first,second);
if(s.equalsIgnoreCase(temp)) count++;
subtext=subtext.substring(second+1);
}
if(count==0)
System.out.print("it not exists");
else
System.out.print("it exists");
}
}
请大伙帮我看看这个程序啊,我搞了好久 了都没有结果,现在只有寄希望于各位大虾了(要求:输入任意的字符串,能够查找到它是否存在,最好还能统计一下这个字符串总共出现了几次,以及它出现的位置.)