📄 countvowels.java
字号:
import java.io.*;
public class CountVowels
{
public static void main (String[] args)
{
String str = new String("Counting the number of vowels");
int i, numChars;
int vowelCount = 0;
System.out.println("The string: " + str);
numChars = str.length();
for (i = 0; i < numChars; i++)
{
switch(str.charAt(i)) // here is where a character is retrieved
{
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
vowelCount++;
}
}
System.out.println("has " + vowelCount + " vowels.");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -