第1个回答 2015-10-14
public class M {
public static int count(String s, char ch) {
int sum = 0;
int length = s.length();
for (int i = 0; i != length; ++i) {
if (ch == s.charAt(i)) {
++sum;
}
}
return sum;
}
public static void main(String [] args) throws Exception{
System.out.println(count("hello, world!", 'l'));
}
}