String test="abacedabcedbcdea"

find the frequency of a , b ,c ,e and d

Recommended Answers

All 4 Replies

4, 3, 3, 3 and 3

commented: Excellent work! +19

You just count the number of times each one appears in the String. A simple web search would tell you that.

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.

Try this simple example:

String s = "asjdhk123uhmsmik,z!?";
for (int i=0;i<s.length();i++) {
  char ch = s.charAt(i);
  System.out.println(ch);
}

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.