In my for-loop below I am trying to add all car IDS associated to a persons with a certain status.
My code compiles and runs, however the size of arrayList: listOfCarIds is remaining 0. I.e. nothing seems to be added
Is there a mistake in how I am implementing this?
for(int i=0 ; i < personsWithStatus.size() ; i++)
{
idOfCarRelatingToPerson = personsWithStatus.get(i).getCarId();
List<String> listOfCarIds = new ArrayList();
listOfCarIds.add(idOfCarRelatingToPerson);
}
listOfCarIdsin each iteration and discarding it. Perhaps you intended to initalise the field not the local variable before the loop.