A basic chat program I wrote has several key words that generate special actions, images, messages, etc. I store all of the key words and special functions in a HashMap. Key wor
Well, you can write:
for(String currentKey : myHashMap.keySet()){
but this isn't really the best way to use a hash-map.
A better approach is to populate myHashMap
with all-lowercase keys, and then write:
theFunction = myHashMap.get(user.getInput().toLowerCase());
to retrieve the function (or null
if the user-input does not appear in the map).