In this program, I want to not only print the results but to save the results as a string. How do I do that? Also, how do I 'return' a string value that can be printed? (This program is removes all the vowels in the 'ad' string except the first letter of the word)
public class RemoveVowels {
public static void main(String[] args) {
String a = "";
remove("Remove all vowels from string except the first letters");
System.out.println();
}
static String remove(String a) {
char c = '\0';
String ss = "";
String s = ("" + a.charAt(0));
String sent = ("" + s);
boolean vowel = false;
boolean first = false;
System.out.print(s);
for (int i = 1; i <= (a.length() - 1); i++) {
c = a.charAt(i);
if (a.charAt(i - 1) == ' ')
first = true;
else
first = false;
if (((c == 'a' || c == 'e') || (c == 'i' || c == 'o')) || (c == 'u' || c == 'y'))
vowel = true;
else
vowel = false;
if ((first == true) || (vowel == false)) {
s = ("" + c);
System.out.print(s);
}
}
return s;
}
}