String str
= "ccc";
String subStr
= "cc";
int strLength
= str
.length();
int subStrLength
= subStr
.length();
int count
= 0;
int index
= str
.indexOf(subStr
);
while (index
!= -1) {
count
++;
index
= str
.indexOf(subStr
, index
+ subStrLength
);
}
System
.out
.println(count
);
若有疑问,欢迎留言 ^ _ ^
转载请注明原文地址:https://blackberry.8miu.com/read-39625.html