public static <T1, T2> void forEachInBoth(List<T1> list1, List<T2> list2, Procedure2<? super T1, ? super T2> procedure)
    {
        if (list1 != null && list2 != null)
        {
            int size1 = list1.size();
            int size2 = list2.size();
            if (size1 == size2)
            {
                for (int i = 0; i < size1; i++)
                {
                    procedure.value(list1.get(i), list2.get(i));
                }
            }
            else
            {
                throw new IllegalArgumentException("Attempt to call forEachInBoth with two Lists of different sizes :"
                        + size1
                        + ':'
                        + size2);
            }
        }
    }
public static < T1 , T2 > void forEachInBoth ( List < T1 > list1 , List < T2 > list2 , Procedure2 < ? super T1 , ? super T2 > procedure ) { if ( list1 != null && list2 != null ) { int size1 = list1 . size ( ) ; int size2 = list2 . size ( ) ; if ( size1 == size2 ) { for ( int i = 0 ; i < size1 ; i ++ ) { procedure . value ( list1 . get ( i ) , list2 . get ( i ) ) ; } } else { throw new IllegalArgumentException ( "Attempt to call forEachInBoth with two Lists of different sizes :" + size1 + ':' + size2 ) ; } } }
For each element in both of the Lists, operation is evaluated with both elements as parameters.