import java.io.*;
public class JVA210{
public static void main(String args[]){
int site;
boolean find,find1;
try{
System.out.println("請輸入字串");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = br.readLine();
System.out.println("請輸入要搜尋的字元或字串");
String str2 = br.readLine();
site = -1;
find = false;
find1 = false;
do{
if( (site = str.indexOf(str2,site+1)) > -1 ){
find = true;
if(!find1) System.out.println("第幾個位置找到了");
find1 = true;
System.out.println(site+1);
}
}while(site != -1);
if(!find)
System.out.println("您要搜尋的的字不在字串中");
}catch(Exception e){
}
}
} |