Can't figure out why I'm not meeting the last two requirements here. There are 26 lines, and there are letters, a space, and a number..
package com.codegym.task.task10.task1012;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/*
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);
}
// create hashmap with alphabet
HashMap<Character, Integer> map = new HashMap<Character, Integer>();
for (char c : abcArray) {
map.put(c, 0);
}
// Read in strings
ArrayList<String> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
String s = reader.readLine();
list.add(s.toLowerCase());
}
// Check letters in map
for (String y : list) {
for (char c : y.toCharArray()) {
int counter = map.containsKey(c) ? map.get(c) : 0;
map.put(c, counter + 1);
}
}
// create array list in case of stringconversion?
ArrayList<String> stringA = new ArrayList<String>();
// printdatshit
for (Map.Entry<Character, Integer> mappair : map.entrySet()) {
System.out.println(mappair.getKey() + " " + mappair.getValue());
// populate the arraylist
//stringA.add(mappair.getKey() + " " + mappair.getValue());
}
// print the arraylist
//for (String s : stringA) {
// System.out.println(s);
//}
}
}