O problema está na parte que comentei. Como posso alterar o código, para que funcione? Eu quero só os números que se repetem e a quantidade de vezes que se repete. Virei a noite tentando, mas não consegui =(
import java.util.Scanner;
public class TesteVetor {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int tam;
System.out.println("Digite o tamanho do vetor");
tam = s.nextInt();
int vetValor[] = new int [tam];
int valor;
int vetRep[] = new int [tam];
int vetCont[] = new int [tam];
int cont =1;
int contJ=1;
int contVet =0;
for(int i =0; i< vetValor.length;i++){
System.out.println("Digite o valor");
valor = s.nextInt();
vetValor[i] = valor;
}
for(int i=0; i<vetValor.length;i++){
for(int j=contJ; j<vetValor.length;j++){
if((vetValor[i] == vetValor[j]) ){ // 1 , 1, 1, 2, 3
//esta estourando, pois quando colocar o mesmo numero repetidamentes, o CONTVET++ acrescenta 1
vetRep[contVet] = vetValor[i];
contVet++;
}
}
contJ++;
}
contJ =1;
contVet =0;
for(int i=0; i<vetValor.length;i++){
cont =1;
for(int j=contJ; j<vetValor.length;j++){
if((vetRep[i] == vetValor[j])){ // 1 , 1, 1, 2, 3
cont++;
vetCont[contVet] = cont;
}
}
contVet++;
contJ++;
}
}
}