I made this method that takes an array of arrays and should return the array most frequent in my array of arrays, but it does print only a[0], which means that one of my expressions doesn't get evaluated. I don't understand which and why.
private static int[] frequency(int[][] a) {
for (int z = 0; z < a.length; z++) {
for (int t = 0; t < a[1].length; t++) {
System.out.print(a[z][t]+" ");
}System.out.println();}
int count = 1, tempCount;
int[] popular = a[0];
int[] temp;
for (int i = 0; i < a.length; i++) {
temp = a[i];
tempCount = 0;
for (int j = 0; j < a.length; j++) {
if ((temp == a[j])&&(i!=j)) {
tempCount++;
}
}
if (tempCount > count) {
popular = temp;
count = tempCount;
}
}
return popular;
}