我有两个数组:
name[] and roll[]
有没有一种方法可以在每个循环中遍历两个数组。两个数组的大小保持不变。
我知道使用两个单独的循环我们可以遍历和实际操作也没什么大不了的,但是我想要这样的事情:
for(String n:name,int r:roll){
//blah blah
}
请多谢一些.....
安库尔
最佳答案
不,您将不得不使用老式的
for(int index = 0; index < name.length; index++) {
//blah blah with name[index] and roll[index]
}