JavaではどのようにStringクラスのindexof方法で単語の出現頻度を得ますか?

668 ワード

public class Test{

public static void main(String[] args) {
String s="hello jack hello look me to see nohello";
String target="hello";//
int count=0;
while(s.indexOf(target)>=0){
s=s.replaceFirst(target, "");
System.out.println(s);
count++;
}
System.out.println(target+" :"+count);
}

}