title: How can I access the previous/next element in an ArrayList?
body: <p>I iterate through an ArrayList this way:</p>
  
  <pre><code>for (T t : list){
    ...
  }
  </code></pre>
  
  <p>When I did this, I never thought I had to access the previous and next elements of this element. Now my code is huge. It costs a lot if I rewrite it with:</p>
  
  <pre><code>for (int i = 0; i &lt; list.size(); i++){
    ...
  }
  </code></pre>