943,866 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1006
  • Java RSS
Mar 25th, 2009
0

find the frequency of the character

Expand Post »
String test="abacedabcedbcdea"

find the frequency of a , b ,c ,e and d
Similar Threads
Reputation Points: 2
Solved Threads: 1
Newbie Poster
amarjeetsingh is offline Offline
21 posts
since Feb 2009
Mar 25th, 2009
1

Re: find the frequency of the character

4, 3, 3, 3 and 3
Last edited by masijade; Mar 25th, 2009 at 7:58 am.
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Mar 25th, 2009
0

Re: find the frequency of the character

You just count the number of times each one appears in the String. A simple web search would tell you that.
Reputation Points: 874
Solved Threads: 352
Posting Maven
BestJewSinceJC is offline Offline
2,758 posts
since Sep 2008
Mar 25th, 2009
0

Re: find the frequency of the character

I sure he knows that, he just wants a code handout. Which he won't get.

If he posts his attempt at it, he might get help correcting it, but noone is going to do it for him.
Moderator
Reputation Points: 1471
Solved Threads: 490
Industrious Poster
masijade is offline Offline
4,043 posts
since Feb 2006
Mar 25th, 2009
0

Re: find the frequency of the character

Try this simple example:

Java Syntax (Toggle Plain Text)
  1. String s = "asjdhk123uhmsmik,z!?";
  2. for (int i=0;i<s.length();i++) {
  3. char ch = s.charAt(i);
  4. System.out.println(ch);
  5. }

Also you should always check the API to find more methods that could be useful. In this case, you should have looked the String API
Last edited by javaAddict; Mar 25th, 2009 at 12:18 pm.
Sponsor
Featured Poster
Reputation Points: 1014
Solved Threads: 446
Nearly a Senior Poster
javaAddict is offline Offline
3,259 posts
since Dec 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: largest and 2nd largest numbers
Next Thread in Java Forum Timeline: Introduction and question on position of reult in scanner





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC