package java實用級;
import java.util.Scanner;
import
java.io.InputStreamReader;
public class J210 {
public J210() {
// TODO Auto-generated constructor stub
}
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
System.out.println("請輸入字串");
String str = sc.nextLine();
System.out.println("請輸入要搜尋的字元或字串");
String ctr = sc.nextLine();
int site=str.indexOf(ctr);
int len=ctr.length();
int count=0;
if(site==-1){
System.out.println("顯示要搜尋的字元不在字串中");}
else{
System.out.println("第幾個位置找到了");
do{
System.out.println(site+1-(count*(len-1)));
site=str.indexOf(ctr,site+1);
count++;
}while(site!=-1);
}
}
}