I iterate through an ArrayList this way:
for (T t : list){ ... }
When I did this, I never thought I had to access the previous and next eleme
I think I found the solution it is simple in fact, but I cannot delete this post already because it has answers..
I just added T t = list.get(i); in the second for-loop, all other code remains unchanged.
T t = list.get(i);