Im trying to create a java method that will look at a 2d array and see how many times a number has been entered more than once and then output the count.
So given this array
1 2 3 3
5 6 7 8
8 45 9 45
10 17 18 13
the method will return a count of 3.
So far this is what i have
int dupe=0;
int chk1=0, chk2=0;
for (int row =0; row < dataTable.length; row ++)
{//for 1
for ( int col = 0; col < dataTable[row].length; col++)
{//for 2
if (dataTable[row][col] == dataTable [chk1][chk2])
{//if
dupe++;
}//end if
chk1++;
chk2++;
}//end for 2
}//end for 1
dupe=dupe-1;
return dupe;
however it will not run unless i declare chk1 and chk2 inside the second 4 which just re declares them every time the check is run.