I iterate over an ArrayList as follows:
for (T t : list){ ... }
When I did this, I never thought that I needed to access the previous and subsequent elements of this element. Now my code is huge. It costs a lot if I rewrote it with:
for (int i = 0; i < list.size(); i++){ ... }
java arraylist for-loop
nomnom
source share