title: How do I iterate over multiple lists in parallel in Java?
body: <p>I want to create a function to iterate over multiple lists. Now I know these lists have exactly the same size (and they can have different types too), for example:</p>
  
  <pre><code>List&lt;Integer&gt; list1 = getList1();
  List&lt;String&gt; list2 = getList2();
  List&lt;Long&gt; list3 = getList3();
  list1.size() == list2.size(); // returns true
  list2.size() == list3.size(); // returns true
  </code></pre>
  
  <p>And I want to be able to call a function which takes 3 elements at the same slice in each of these lists so for exemple:</p>
  
  <pre><code>int calculate(int elemList1, String elemList2, long elemList3) {...}
  
  // iterator over the lists in parallel {
      int ret = calculate(elemList1, elemList2, elemList3);
  // }
  </code></pre>
  
  <p>I would like to do the equivalent of what I saw discussed in guava here but doesn't look implemented yet: <a href="http://code.google.com/p/guava-libraries/issues/detail?id=677" rel="nofollow">http://code.google.com/p/guava-libraries/issues/detail?id=677</a></p>
  
  <p>They talk about doing Iterators.interleave or Iterators.zip and I would like to do something similar but I haven't been able to, so can someone please help me a bit? Thanks!</p>
  
  <p>I would prefer to not have to get the size of one list and iterate over them by index, because in the future i can have lists of different sizes so i would like to use only 1 way to do this.</p>