我是初學Java的人。我有3個ArrayLists,所有ArrayLists都包含與特定主題有關的數據,因此具有相同的長度。我想遍歷數組並執行一些操作,如下圖所示:使用相同索引遍歷多個數組列表
public void example(){
ArrayList<Long> ID = new ArrayList<Long>;
ArrayList<Integer> AcNo = new ArrayList<Integer>;
ArrayList<Integer> Vnum = new ArrayList<Integer>;
//get ID and AcNo from user, compare it in the ArrayList, get the corresponding Vnum
// for the Vnum from previous step, compare it with the next Vnum and get corresponding ID and AcNo until some *condition* is satisfied.
}
如何在Java中執行此操作?我看到了迭代器的例子,但我不確定這樣做的正確方法!請幫忙。