I have created a method that returns me the index of the first occurence of an element in list in this way
public int getOccurrenceIndex(ArrayList<Object> list, Object o){
Object tmp;
for(int i=0; i<list.size(); i++){
tmp=list.get(i);
if(tmp.equals(o)){
return i;
}
}
return -1;
}
I want to use this with different arrayList for example with
ArrayList<Car> carList, Car c
or
ArrayList<Person> personList, Person p
etc.
without define a separate method for each type
Any suggestion?