I think it's pretty messy, but it shows the correct output. Why does it fail the task?
package com.codegym.task.task10.task1012;
import java.io.*;
import java.util.*;
/*
Number of letters
*/
public class Solution {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
// Alphabet
String abc = "abcdefghijklmnopqrstuvwxyz";
char[] abcArray = abc.toCharArray();
ArrayList<Character> alphabet = new ArrayList<>();
for (char letter : abcArray) {
alphabet.add(letter);
}
// Read in strings
ArrayList<String> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
String s = reader.readLine();
list.add(s.toLowerCase());
}
int[] numArray = new int[] {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
ArrayList<Integer> numbers = new ArrayList<>();
for(String x : list) {
char[] array = x.toCharArray();
ArrayList<Character> charas = new ArrayList<>();
for (char letter : array) {
charas.add(letter);
}
Collections.sort(charas);
for(Character y : charas) {
int i = 0;
if(alphabet.contains(y)) {
if(y == alphabet.get(i)) {
numArray[i]++;
}
else if(y != alphabet.get(i)) {
i++;
for( ; i < 25 ; i++) {
if(y == alphabet.get(i)) {
numArray[i]++;
}
}
}
}
}
}
for(Integer x : numArray) {
numbers.add(x);
}
for(int i = 0; i < 26; i++) {
System.out.println(alphabet.get(i) + " " + numbers.get(i));
}
}
}