You may retrieve index of any element in your list using indexOf
method :
List<String> listA = new ArrayList<String>();
//Lots of code adding and removing things from listA, imagine listA now contains approx 10,000 records
String str = "element 0"
listA.add(str);
int index = listA.indexOf(str)
If you are only concerned by the index of the last element, the list javadoc says : " add(E e)
Appends the specified element to the end of this list (optional operation)."
so you can use :
List<String> listA = new ArrayList<String>();
//Lots of code adding and removing things from listA, imagine listA now contains approx 10,000 records
listA.add("element 0");
int index = listA.size()-1 //minus 1 because index start at 0
As you seem concerned to access element by index ( identifier ?) you should take a look at Map :
Map<int, String> mymap = new HashMap<int, String>();
mymap.add(1, "element1");
mymap.add(2, "element2");
mymap.add(3, "element3");
mymap.get(3);//return "element3"