集册 Java实例教程 使用StringBuilder标记元音

使用StringBuilder标记元音

欢马劈雪     最近更新时间:2020-01-02 10:19:05

537
使用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 == 
展开阅读全文