I receive a list of words and assigns them to write all the words that start and end with a vowel. I need to write a MasinaDeTeme class that contains a public Word filtering method. The method will receive as a parameter a string of String (String []) and will return a StringBuffer that will contain all the words with the required property concatenated in the order in which they appear in the string.
Here is the part of my cod where is my problem:
public static StringBuffer filtrareCuvinte(String[] cuvinte){
for(int i = 0; i < cuvinte.length; i++)
if(isVowel(cuvinte[i].charAt(0)) && isVowel(cuvinte[i].charAt(cuvinte.length - 1)))
s.append(cuvinte[i]);
return s;
}
}
I receive an error: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 3
I think its because of the length. Any suggestions?