I have String array with some components, this array has 5 components and it vary some times. 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.
This how far I have come:
String[] elements = { "a", "a","a","a" };
for( int i = 0; i <= elements.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.
}
How can I accomplish this?
See Question&Answers more detail:os