Below program will compare elements of 2 array and display duplicates elements.
package com.seleniumtest;
public class CommonArrayElements
{
public static void main(String args[])
{
int[] firstArray = {1, 4, 2, 3, 7, 5};
int[] secondArray = {3, 4, 1, 6};
for(int i=0; i < firstArray.length; i++)
{
for(int j=0; j<secondArray.length; j++)
{
if(firstArray[i] == secondArray[j])
{
System.out.println(firstArray[i] + " ");
}
}
}
}
}
Comments