Java - iterate trough string array
<p>I have String array with some components, this array has sometimes 5 components and some times 6 components. What I would like to do is to iterate through that array and get the first component and the component next to that one. So the first time I would get the component number one and the component number 2, the second time would get the number 2 and 3, the third time number 3 and 4... And so on until you get to the last component. </p>

<p>This how far I have come: </p>

<pre><code>String[] elements = { "a", "a","a","a" };

for( int i = 0; i &lt;= element.length - 1; i++)
{
    // get element number 0 and 1 and put it in a variable, 
    // and the next time get element      1 and 2 and put this in another variable. 
}
</code></pre>

<p>How can I accomplish this?</p>
