package com.bjpowernode;
public class MyTest {
public static void main(String args[]) {
String sc = "want you to know one thing";
char c[] = sc.toCharArray();
int n1 = 0;
int n2 = 0;
for (int x = 0; x < sc.length();x++){
if (c[x] ==('n')){
n1++;
} else if (c[x] ==('o')){
n2++;
}
}
System.out.println("n的个数:" + n1);
System.out.println("o的个数:" + n2);
}
}
JAVA 开发实战经典 第二版 第五章 练习题 第 P157 T3
最新推荐文章于 2024-04-05 04:17:55 发布