/******************************************************************************
Online Java Compiler.
Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.
*******************************************************************************/
public class Main
{
public static boolean isVowel (char ch){
return "AEIOUaeiou".indexOf(ch) != -1;
}
public static String replaceVowels (String phrase, char ch) {
char currChar;
StringBuilder result = new StringBuilder(phrase);
for (int i = 0; i< phrase.length(); i++) {
currChar = result.charAt(i);
if (isVowel(currChar)) {
result.setCharAt(phrase.indexOf(currChar),ch);
}
}
return result.toString();
}
public static void testCaesar() {
String replaced = replaceVowels("Hello World!", '*');
System.out.println(replaced);
}
public static void main(String[] args) {
testCaesar();
}
}