public static <T1,T2>void forEachInBoth(List<T1> list1,List<T2> list2,Procedure2<? super T1,? super T2> procedure){
  if (list1 != null && list2 != null) {
    if (list1.size() == list2.size()) {
      if (list1 instanceof RandomAccess && list2 instanceof RandomAccess) {
        RandomAccessListIterate.forEachInBoth(list1,list2,procedure);
      }
 else {
        Iterator<T1> iterator1=list1.iterator();
        Iterator<T2> iterator2=list2.iterator();
        int size=list2.size();
        for (int i=0; i < size; i++) {
          procedure.value(iterator1.next(),iterator2.next());
        }
      }
    }
 else {
      throw new RuntimeException("Attempt to call forEachInBoth with two Lists of different sizes :" + list1.size() + ':'+ list2.size());
    }
  }
}

public static < T1 , T2 > void forEachInBoth ( List < T1 > list1 , List < T2 > list2 , Procedure2 < ? super T1 , ? super T2 > procedure ) { if ( list1 != null && list2 != null ) { if ( list1 . size ( ) == list2 . size ( ) ) { if ( list1 instanceof RandomAccess && list2 instanceof RandomAccess ) { RandomAccessListIterate . forEachInBoth ( list1 , list2 , procedure ) ; } else { Iterator < T1 > iterator1 = list1 . iterator ( ) ; Iterator < T2 > iterator2 = list2 . iterator ( ) ; int size = list2 . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) { procedure . value ( iterator1 . next ( ) , iterator2 . next ( ) ) ; } } } else { throw new RuntimeException ( "Attempt to call forEachInBoth with two Lists of different sizes :" + list1 . size ( ) + ':' + list2 . size ( ) ) ; } } }
iterates over both lists together , evaluating procedure2 with the current element from each list .
