CPE 103 Lab Activity
|
// Returns the number of elements in both c1 and
c2
// Assumes no duplicates in either list.
public static int intersect ( List<Integer> c1,
List<Integer> c2 )
{
int count = 0;
for( int i = 0; i < c1.size( );
i++ )
{
int item1
= c1.get( i );
for( int j
= 0; j < c2.size( ); j++ )
{
if( c2.get( j ) == item1 )
{
count++;
break;
}
}
}
return count;
}