Hi! Can anyone give me a hint as to why my linear search won't work? When a number is entered in the index textfield and click the show button, that element should be displayed in the element textfield. I get all sorts of exception messages. Anything would be appreciated. Here's the code: //ArrayDemo.java
Thanks, Marie [ January 31, 2004: Message edited by: Jim Yingst ]
I didn't examine the program extremely closely, but one major problem is that there are two variables named "list": one is a member of ArrayDemo; this one is never initialized. Another is local to main(), and this one is the one that gets initialized. All the methods of ArrayDemo try to use the uninitialized one. To fix this, you could move the code that creates the array and populates it from main() into the ArrayDemo constructor, being careful to remove the line "int list" that declares the local variable, so that it's the member that gets initialized instead.