Provide an iterator over the contents of two lists simultaneously?

前端 未结 11 2070
逝去的感伤
逝去的感伤 2020-12-03 04:45

Suppose I have this:

public class Unit {

    ...

    List mobileSuits;
    List pilots;

    ...
}
         


        
11条回答
  •  悲&欢浪女
    2020-12-03 05:27

    for(int i=0; i < mobileSuits.size(); i++) {
      MobileSuit suit = mobileSuits.get(i);
      Pilot pilot = pilots.get(i);
      ...
    }
    

提交回复
热议问题