I am having problems at the moment of initialize the array and returning it. The method is suppose to return common items of a generic array, but i cant initialize array "a" or returning it. Any advice??
public static <T> T[] commonItems( T[] arr1, T[] arr2)
{
T[] a;
int pos = 0;
for( int i = 0; i < arr1.length; i++)
{
for(int j = 0; j < arr2.length; j++)
{
if(arr1[i].equals(arr2[j]))
{
a[pos] = arr1[i];
pos++;
}
}
}
return a;
}