题目:
统计"let there be light"有多少个以l开头的单词
代码:
public static void main(String[] args) {
String sentence = "let there be light";
int count = 0;
String[] str = sentence.split(" ");
for (int i = 0; i < str.length; i++) {
if ('l' == str[i].charAt(0)) {
count++;
}
}
System.out.println(count);
}