On Aug 14, 9:50 pm, mesfin <[email protected]> wrote: > I have a little problem in this home work which displaying the Correct > search result ,However it does not display the wrong search result on > the dialog...I got the following Error When i insert a wrong word in > to the input dialog. > > Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 8 > at OwnWhileProject.main(OwnWhileProject.java:40) > Java Result: 1 > > Any one can fox the problem, There is a logic error in your program. You have first to scan the whole array of names before being able to say there is no match. That is in a first step you deal only with foundName variable inside the while loop. Then once you know it is true of false, you can set the result outside the while loop and print it. Also the increment of i should be at the end of the while loop not at the top, otherwise you never read the first name and consequently get an outofbounds exception.
Michèle Garoche -- To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en
