I have an array for example:
1 4 7
1 3 4 6 7
1 2 3 4 5 6
I have to see the numbers that repeat on ALL lines, in the example, should be the numbers: 1 and 4. For they are repeating on all lines.
Vector<Integer> validos = new Vector<Integer>();
int cont = 0;
for (int linha = 0; linha < resultado.length; linha++)
{
for (int coluna = 0; coluna < resultado.length - 1; coluna++)
{
for (int linha2 = (linha + 1); linha2 < resultado.length; linha2++)
{
for (int coluna2 = 0; coluna2 < resultado.length - 1; coluna2++)
{
if(resultado[linha][coluna] == resultado[linha2][coluna2])
{
cont ++;
}
}
}
}
}
Where the array is the variable resultado
, which is a int[][]
, I tried to implement a cont
that if there were the number on all rows it would then count the number of rows in the array, eg 3.
Only the code is not working.
The goal is to get these repeated numbers and put them in Vector validos