统计字符串里某个字符的个数:
String string = "字符串";
char[] temp = string.toCharArray();
for(int i = 0, count = 0; i < temp.length; i++){
//需要保存个数可将 count在for循环外定义等
if(temp[i] == '字符'){++count;}
}
string = null;
temp = null;
微信扫一扫
统计字符串里某个字符的个数:
String string = "字符串";
char[] temp = string.toCharArray();
for(int i = 0, count = 0; i < temp.length; i++){
//需要保存个数可将 count在for循环外定义等
if(temp[i] == '字符'){++count;}
}
string = null;
temp = null;
相关推荐