看看怎么写程序。。
[CODE]
/**
*
*/
package com.test;
/**
* @author 支离破碎
*
*/
public class CountLetters {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String[] letters = {"a","e","i","o","u"};
System.out.println(getCountLetters("hello China!",letters));
}
public static int getCountLetters(String countStr,String[] letters){
int returnNum=0;
for(int i=0;i<countStr.length();i++){
for(int j=0;j<letters.length;j++){
if(letters[j].equalsIgnoreCase(countStr.substring(i,i+1))){
returnNum++;
}
}
}
return returnNum;
}
}
[/CODE]