I want to make a method that will check if an element has already been added to a list, if it is already going to increment 1. This is the class I made, but it is giving error.
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;
}
}