Duplicates can occur in two lists. Often this is
caused by data-entry mistakes.
For example:
String[] oldNames = {"Anna" , "Bob" , "Carla" , "Doug",
"Eddy"};
String[] newNames =
{"Carl","Betty","Eddy","Freddy"};
This isn't necessarily an error - perhaps there are two people named
"Eddy" -
but sometimes it is a mistake.
Write a method that compares two String[] arrays, looks for
duplicates,
and prints all the duplicate names.
public void findDuplicates(String[] first, String[]
second)
{
for(int a = 0; a <
first.length; a = a+1)
{
for(int b =
0; b < second.length; b =
b+1)
{
if(
first[a].equals( second[b] )
)
{
System.out.println( first[a]
);
}
}
}
}