Find common strings in the given two arrays - Java Quiz Question



Write a program to find common strings in the given two arrays.

Input (String Array 1, String Array 2) Output String Array
{CSE, ECE, EEE, IT, MEC, Civil}
{CSE, BME, ECE, Civil, Chemical}
{CSE, ECE, Civil}
{Sachin, Rohit, Yuvraj, Raina, Harbhajan}
{Sachin, Raina, Shewag, Dhoni}
{Sachin, Raina}
{} EMPTY ARRAY {}
null - NULL ARRAY null

class GetCommonStringsInTwoDifferentArrays

{    public static void main(String s[])
    {
        String array1[] = {"CSE", "ECE", "IT", "MEC", "EEE", "Civil"};
        String array2[] = {"CSE", "ECE", "Civil"};
        String[] outputArray = getCommonStrings(array1, array2);
        System.out.println("The common strings in the arrays:");
        for(String outputString : outputArray){
            System.out.print(outputString + ", ");
        }

    }


public static String[] getCommonStrings(String[] array1, String[] array2)
{
String[] result = null;
//Write a code to get common strings in two different arrays and store them into result
return result;
}
public static int getCommonStringsCount(String[] array1, String[] array2)
{
int result = 0;
//Write a code to get common strings count in two different arrays and assign to it result
return result;
}
}