Count? If you use the charAt(index) method of String, you can walk through the characters of the String one by one. As you bump into a new character you can add it to a Map of some sort, perhaps a HashMap or a TreeMap, using the character itself as the key and the element can be the count of how many you have found.
Kevin sounds like a school assignment so most people probably will not just blindly give the answer - the whole point of going to school is to learn... What do you have so far? any code written? or even a rough outline of what steps you need - show us what you have and we'll point you in the right direction. In case you dont even know where to start here is a rough thought process to use... Steps --get the string --look at each letter and remember how many times it occured --report your findings now you can break each of these into even smaller pieces until you find a piece you know how to do then build off of that... get the string (depends on the assignment requirments) -- either parse the command line argument or -- prompt for it count the letters: --need to look at each letter of the string in order making sure to only count each letter once -- need to keep track of each letter counted and the total number of occurances of each report your findings (depends on requirments) -- System.out.println ..... Then break these steps down again... Eventually you'll get to a point where it is a simple matter of writing a few lines of code to perform a step. Not what you wanted but I hope it helps
Joined: Aug 24, 2001
Dave, this isn't a school assignment, I'm past that already... I'm learning Java at work... just trying to figure somethings out for help with building certain applications. I program in SAP under the ABAP/4 environment, and they now have a java side in the portals end of SAP and they are starting to incorporate java into their web enablement of their transactions [ February 05, 2002: Message edited by: kevin schmidt ]