I am a beginner in Java. I need to compare two arrays of string and find out if any value from the first array matches any value in second array?
Here is my function which does not work as expected,
public static boolean CheckStatAppearinLeftAndRight1(String[] array1, String[] array2)
{
boolean b = false;
for (int i = 0; i < array2.length; i++)
{
for (int a = 0; a < array1.length; a++)
{
if (array2[i] == array1[a])
{
b = true;
break;
}
else
{
b = false;
}
}
}
return b;
}
Can someone please point out the issue here?