package 字符串2;
public class TestString {
public static void main(String[] args) { String str = "Returns a new character sequence that is a subsequence of this sequence"; int count = 0; int index = 0; String strTofind = "sequence"; while((index = str.indexOf(strTofind))!=-1){ count++; str = str.substring(index+strTofind.length()); } System.out.println("str字符串中所含的sequence子串的个数:"+count); }
}
时间: 2024-10-14 07:13:46