I'm trying to create a program that lets you put any data into a table and you can perform functions like count how many words there are in a column, row etc. Is using a HashMap the best way to go about this?
If not what can you recommend?
At the moment I'm struggling to count each of the letters and it's adding 1 to each of the values each time giving a = 8, b and c = 0
public void main(String[] args){
map.put("0", "a");
map.put("1", "b");
map.put("2", "c");
map.put("3", "a");
map.put("4", "b");
map.put("5", "a");
map.put("6", "b");
map.put("7", "c");
for(Map.Entry ent : map.entrySet()){
if(map.containsValue("a")){
x++;}
else if(map.containsValue("b")){
y++;}
else if(map.containsValue("c")){
z++;}
}
System.out.println("a = " + x);
System.out.println("b = " + y);
System.out.println("c = " + z);