//输入字符串然后与自己定义的数组进行对比,并输出重复次数。
public class Test11 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("请输入字符串:");
String num = input.next();
char[] array = { 'a', 'e', 'i', 'o', 'u' };
int count = 0;
for (int i = 0; i < num.length(); i++) {
char ch = String.valueOf(num).charAt(i);
for (int j = 0; j < array.length; j++) {
if (ch == array[j]) {
count++;
}
}
}
System.out.println(count);
}
}
-----------------------------------------------------------------------------------
public class Test26 {
public static void main(String[] args) {
// TODO Auto-generated method stub
String str = "asdfghjkl4645678";
int count = 0;
char[] array = str.toCharArray();
for (int i = 0; i < array.length; i++) {
if (array[i] >= '0' && array[i] < '9') {
count++;
}
}
System.out.println(count);
}
}