Estou com um trabalho para fazer em que eu devo achar os 5 valores que mais saíram no sorteio da Mega-sena, já li o arquivo .csv e os valores estão salvo em um Array de count. Porém, não consigo achar uma forma de fazer isso, vou postar o código pra vocês aqui:
public static void main(String[] args) throws IOException {
Scanner scanner = new Scanner(System.in);
int[] aposta = new int[6];
String[] novoArray = new String[5];
int valores = 0;
int contador = 0;
String[] numero = new String[5];
String[] quantidade = new String[5];
for(int i = 0; i < 6; i++) {
valores++;
System.out.println("Digite o " + valores + "° valor:");
aposta[i] = scanner.nextInt();
}
String arrayNovo[] = new String[aposta.length];
for(int j = 0; j < 6; j++) {
arrayNovo[j] = Integer.toString(aposta[j]).format("%02d", aposta[j]);
}
File csvFile = new File("C:/Users/lucas/Desktop/mega.csv");
BufferedReader br = new BufferedReader(new FileReader(csvFile));
String line = "";
try {
while ((line = br.readLine()) != null) {
String[] count = line.split(",");
String[] repeticao = new String[count.length];
int valor = 0;
int repetiu = 1;
for(int i = 0; i < count.length; i++) {
repeticao[i] = count[i];
}
for(int i = 0; i < count.length; i++) {
for(int j = 2; j < 8; j++) {
for(int c = 2; c < 8; c++) {
}
}
}
for(int i = 0; i < 2255; i++) {
for(int j = 2; j < 8; j++) {
for(int c = 0; c < 6; c++) {
if(arrayNovo[c].equals(count[j])) {
contador = contador + 1;
} else {
contador = contador + 0;
}
}
}
if(contador == 0) {
continue;
} else if(contador > 0){
System.out.println("No " + count[i] + "° jogo, você acertaria: " + contador + " apostas.");
contador = 0;
break;
}
}
for(int i = 0; i < repeticao.length; i++) {
System.out.print(repeticao[i]);
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}