我有一个带有一些组件的字符串数组,这个数组有5个组件,它有时会发生变化。我想要做的是迭代该数组,并获得第一个组件和该组件旁边的组件。所以第一次得到元件号1和元件号2,第二次得到2和3,第三次得到3和4…依此类推,直到您到达最后一个组件。
这就是我所走的路:
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.
}
我如何才能做到这一点呢?
https://stackoverflow.com/questions/6707695
复制相似问题