I'm trying to iterate through an ArrayList and print each element in it but it only outputs the first element in the ArrayList. Then there's an infinite loop and it keeps printing out the first element.
ArrayList<String> startTime = new ArrayList<String>();
for (int i = 0; i < startTime.size(); i++) {
String getTime = startTime.get(i);
getTime = convertTime(getTime);
startTime.add(i, getTime);
System.out.println(startTime.get(i));
}
startTime.add(i, getTime);in the loop - you are adding an element to the list in each iteration of the loop. Why did you add that line? Remove it.