怎么能快速地在一个有10万个字符长度的字符串中快速地统计某个字符出现的总次数?正则表达式或其他方法吗
如何能快速地在一个有10万个字符长度的字符串中快速地统计某个字符出现的总次数????正则表达式或其他方法吗?
如何能快速地在一个有10万个字符长度的字符串中快速地统计某个字符出现的总次数????
除了正则表达式或其他方法吗?
------解决思路----------------------
int count = 0;
int index = 0;
while (true) {
index = result.indexOf(target, index + 1);
if (index > 0) {
count++;
} else {
break;
}
}
System.out.println(count);
如何能快速地在一个有10万个字符长度的字符串中快速地统计某个字符出现的总次数????
除了正则表达式或其他方法吗?
------解决思路----------------------
int count = 0;
int index = 0;
while (true) {
index = result.indexOf(target, index + 1);
if (index > 0) {
count++;
} else {
break;
}
}
System.out.println(count);