title: Accessing Array in Loop Java
body: <p>I have a vector that is for example: [ 0, 4, 5, 1 , 2, 3]</p>
  
  <p>What I want is to go through the vector and assign in this way:</p>
  
  <p>1st iteration: a = 0; b = 4; c = 5;</p>
  
  <p>2nd iteration: a = 1; b = 2; c = 3;</p>
  
  <p>and so on..</p>
  
  <p>I tried this way: </p>
  
  <pre><code>for (int i = 0; i &lt; Vec.size() - 2; i+=3) {
  
    for (int j = i + 1; j &lt; Vec.size() - 1; j+=3) {
  
        for (int k = j + 1; k &lt; Vec.size(); k+=3) {
  
        area = triangle_area_calculator(Vec.get(i), Vec.get(j), Vec.get(k));
  
        }
    }
  </code></pre>
  
  <p>}</p>
  
  <p>But of course this only work in the first iteration and it gets messed up in the second. </p>
  
  <p>Thanks in advance! </p>