I have this two ArrayLists. I need to iterate through the stationNames Array and get the index. Then return the value of the same index of stationIDs array. How do i achieve this? Please help me. The existing solutions on stackoverflow didn't work on this. I am new to android development.
When i iterate through the Array like the following code it give an error saying Array type expected; found: java.util.ArrayList<java.lang.String>
ArrayList<String> stationNames = new ArrayList<String>();
ArrayList<String> stationIDs = new ArrayList<String>();
stationName = "Hello"
int index = -1;
try {
for (int i = 0; i < stationNames.length; i++) {
if (stationNames[i].equals(stationName)) {
index = i;
break;
}
}
}
catch (Exception e){
Log.d("Excetion!",e.getLocalizedMessage());
}
return stationIDs[index];