0
I want to do a method that will check if an element has already been added to a list, if it will already increment 1. This is the class I made, but it is a mistake.
public class Rascunho {
private int [] vetor;
private int countValor ;
private int c = 0;
public Rascunho () {
vetor = new int [7];
countValor = 0;
}
public void insertValor (int valor) {
countValor ++;
int i = 0;
vetor [i] = valor;
}
public int verificar () {
for (int i = 0; i<countValor-1; i++)
for (int j= 0; j < countValor; j++) {
if (vetor[j+1] == vetor[i]) {c++;}
}
return c;
}
}
what error is happening?
– Lucas Miranda