HashMap freqMap = new HashMap();
//FOR loop through chars goes here
if (freqMap.containsKey(character))
freqMap.put(character, freqMap.get(character)+1);
else
freqMap.put(character, 1);
Don't expect that code to work with a copy n paste job, you'll still need to do some casting and boxing.
You can even condense that 4-line IF statement into a single line using the alternative IF structure. Once you've solved this problem successfully, I'll show you how if interested.
Reputation Points: 92
Solved Threads: 51
Practically a Posting Shark
Offline 856 posts
since Mar 2004