HI i have a method that performs a linear search to find a given vowel. The vowel parameter is a given vowel, while vowel[] is the array with all the vowels.
After running the program i get the error:
Exception in thread "main" java.lang.Array IndexOutOfBound sException: 3
at Main.DisplayFir stAppearance(Ma in.java:78) --> Line 7
3 being the number of values in the array.
Anyone know how to ovr come this i noe its somthing to do with the value not being with range or somthing.
Code:
public static void DisplayFirstAppearance (char vowel, char vowels[]) {
boolean element_found = false;
int index;
for (index = 0; element_found == false && index < NoVowels; ++index); {
if (vowels[index] == vowel) { // Error Here
element_found = true;
}
if (element_found) {
System.out.println("The vowel: " + vowel);
System.out.println("First appears: " + vowels[index]);
}
else
System.out.print(+ vowel);
System.out.println(" Vowel not found");
}
Exception in thread "main" java.lang.Array IndexOutOfBound sException: 3
at Main.DisplayFir stAppearance(Ma in.java:78) --> Line 7
3 being the number of values in the array.
Anyone know how to ovr come this i noe its somthing to do with the value not being with range or somthing.
Comment