I am trying to write a compression program that removes vowels, using a String instead of an array, per the assignment specifications, but I keep getting this error. I am totally lost. Could use some help.
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
static String stringCompress(String msg) {
String vowels = VOWELS;
String output = "";
String localChar;
for (int i = 0; i < msg.length(); i++) {
localChar = String.valueOf(msg.charAt(i));
if (!VOWELS.contains(localChar)|| Character.isWhitespace(msg.charAt(i-1))){
output += localChar;
}
}
return output;