I have a String array with some components, this array has 5 components, and it changes several times. What I would like to do is iterate over this array and get the first component and the component next to it. So the first time I get component number one and component number 2, the second time I get the number 2 and 3, the third time I get the number 3 and 4 ... And so on, until you get to the last component.
This is how far I came:
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 do this?
java collections arrays
ErikssonE Jul 15 '11 at 13:27 2011-07-15 13:27
source share