【源码分享】统计字符串中字符的出现次数
【原创】public class StringTest {
public static void main(String[] args) {
String s = new String("123123123123");
int count = 0;
for (int i = 0; is.length(); i++) {
i = s.indexOf("1",i);
if (i == -1) break;
count++;
}
System.out.println("这个字符出现次数为"+count);
}
}
页:
[1]