6 回答
已采纳
lzjccc
TA贡献23条经验 获得超7个赞
int i=0;
int j=0;
String str="want you to know one thing";
for(i=0;i<str.length();i++){
if(str.charAt(i)=='n'){
j++;
}
}
System.out.print(j);
badbomb
TA贡献16条经验 获得超10个赞
String str = "want you know one thing";
int num=0;
for(int i=0; i<str.length(); i++){
if(str.charAt(i) == 'n'){
num++;
}
}
System.out.println(num);
adn_boy
TA贡献11条经验 获得超0个赞
String str = "want you to know one thing";
int n = 'n';
char [] chars = str.toCharArray();
int count = 0;
for (int i = 0;i < chars.length;i++){
if((int)chars[i] == n){
count ++;
}
}
损失函数
TA贡献114条经验 获得超93个赞
亲测可用
String ss = "want you to know one thing";
byte[] ssb= ss.getBytes();
byte[] s = "n".getBytes();
int i = 0;
for (byte b : ssb) {
if(b == s[0]){
i++;
}
}
System.out.println(i);
六道骸
TA贡献30条经验 获得超6个赞
String s= "want you to know one thing";
String[] ssss = s.split("n");
ssss 的长度-1;
添加回答
举报
0/150
提交
取消
