@Test
public void test1(){
String sLong = "123131241242421";
String sShort ="24";
int i = 0;
//短字符串出现的次数
int num = 0 ;
while (i>= 0){
i = sLong.indexOf(sShort, i);
if (i<0) break;
i++;
num++;
}
System.out.println("num ="+num);
}
短字符串在长字符串中出现的次数
最新推荐文章于 2021-05-31 22:56:55 发布