使用StringBuilder标记元音
import java.util.Scanner; public class StringBuilderApp {/*nowjava.com - 时代Java 提 供*/ static Scanner sc = new Scanner(System.in); public static void main(String[] args) { System.out.print("Enter a string: "); String s = sc.nextLine(); StringBuilder sb = new StringBuilder(s); int vowelCount = 0; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if ( (c == 'A') || (c == 'a')/*来 自 时代Java公众号 - N o w J a v a . c o m*/ || (c == 'E') || (c == 'e') || (c == 'I') || (c == 'i') || (c == 'O') || (c == 'o') || (c ==