public static void sameSize ( final Collection < ? > collection1 , final Collection < ? > collection2 , final String collection1Name , final String collection2Name ) { notNull ( collection1 , collection1Name ) ; notNull ( collection2 , collection2Name ) ; if ( collection1 . size ( ) != collection2 . size ( ) ) { throw new IllegalArgumentException ( "expecting " + maskNullArgument ( collection1Name ) + " to have the same size as " + maskNullArgument ( collection2Name ) ) ; } }
Checks that the collections have the same number of elements otherwise throws an exception