Hey guys everything is fine with my code it works and is verified succesfully.
I am posting this so that you guys could suggest me any further modifications in my code(i.e if there is some unnecessary code, or may be i could have written some logic better etc).
Go through my code and suggest me if any.
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());
}
//Start of the logic to get character count
int[] count = new int[alphabet.size()];
for (String i : list){
char[] words = i.toCharArray();
for (char k : words){
for (int j = 0; j < alphabet.size(); j++){
if (alphabet.get(j).equals(k)){
count[j]++;
}
}
}
}
//end of the logic to get character count
ArrayList<String> list1 = new ArrayList<>();
for (int i = 0; i < alphabet.size(); i++){
list1.add(alphabet.get(i) + " " + count[i]);
}
for (String i : list1){
System.out.println(i);
}
}
}