Hi guys,
Im trying to write a very small and simple method that will find an element from a arrayList and return it. the list contains instances of a class called People. I tried using the indexOf method to find the index of the desired element and then the get() method to return the element using the previously found index.
I just keep getting the java.lang.ArrayIndexOutOfBoundsException: -1 error.
the code I have is:
public Names findPerson(String aString) { int personIndex = people.lastIndexOf(aString); return people..get(personIndex); }
any help is much appreciated.