Expand|Select|Wrap|Line Numbers
- 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.ArrayIndexOutOfBoundsException: 3
at Main.DisplayFirstAppearance(Main.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.