java 怎样从一个string字符串中判断某个字母出现的次数
String str = "中国 台湾 sd d";int x=0;//遍历数组的每个元素for(int i=0;i<=str.length()-1;i++) {String getstr=str.substring(i,i+1);if(getstr.equals("d")){
·
String str = "中国 台湾 sd d";
int x=0;
//遍历数组的每个元素
for(int i=0;i<=str.length()-1;i++) {
String getstr=str.substring(i,i+1);
if(getstr.equals("d")){
x++;
}
}
System.out.print(x);
更多推荐



所有评论(0)