| Author |
Using HashMap need to count the frequency of letters in a String
|
Abhinav satyam Gupta
Greenhorn
Joined: Aug 15, 2008
Posts: 2
|
|
Hello Friends,
I wanted to write a prog which can count the frequency of letters in a String using HashMap.
Would seek your assistance to do so
|
 |
Christophe Verré
Sheriff
Joined: Nov 24, 2005
Posts: 14672
|
|
|
Where did you get so far ?
|
[My Blog]
All roads lead to JavaRanch
|
 |
Lucas Franceschi
Ranch Hand
Joined: Nov 10, 2008
Posts: 106
|
|
would you mind telling us a little more about your problem?, please help us, so that we can help you
|
Lucas Franceschi
Software Developer for SGI Sistemas, lukas1596@gmail.com
|
 |
Steven Satelle
Greenhorn
Joined: Sep 30, 2008
Posts: 22
|
|
You could try creating a HashMap<Character, int>, setting the keys to each letter your interested in. Then iterating through each Character in the String, and if (key<Character> .exists()) { value ++; }
now, there you go in sudo sudo code
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
Steven Satelle wrote:You could try creating a HashMap<Character, int>, setting the keys to each letter your interested in. Then iterating through each Character in the String, and if (key<Character> .exists()) { value ++; }
That should be HashMap<Character, Integer> of course
And if the key does not exist, you have encountered the first occurrance. It's easy to determine what the value would have to be then.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Balagopal Kannampallil
Ranch Hand
Joined: Oct 18, 2004
Posts: 111
|
|
Hi Abhinav,
Can you elaborate a little more about your requirement.
|
Bala
SCJP 5.0
Gonna hunt down SCWCD soon..
|
 |
 |
|
|
subject: Using HashMap need to count the frequency of letters in a String
|
|
|