Java examples for Language Basics:StringBuilder
Use StringBuilder to Mark Vowel
import java.util.Scanner; public class StringBuilderApp { static Scanner sc = new Scanner(System.in); public static void main(String[] args) {/*from w w w .ja v a 2 s . c o m*/ 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') || (c == 'E') || (c == 'e') || (c == 'I') || (c == 'i') || (c == 'O') || (c == 'o') || (c == 'U') || (c == 'u') ) { sb.setCharAt(i, '*'); } } System.out.println(s); System.out.println(sb.toString()); } }