public static int countCharNumbers(String str, int index){
if(str == null || index < 0)
throw new IllegalArgumentException("输入的参数不合法!");
char c = str.charAt(index);
int count = 0;
for(int i = 0; i < str.length();){
int j = str.indexOf(c, i);
if(j < 0){
break;
}else{
count++;
i = j + 1;
}
}
return count;
}
function countStr(str,s){ return str.split(s).length-1; } countStr("test_for_test","t")