Results 1 to 4 of 4
  1. #1
    satheeshtech is offline Member
    Join Date
    Jul 2009
    Posts
    18
    Rep Power
    0

    Default How to count occurences of charectors in string?

    Hi all,
    I have a String object like String s="Hello";
    Here how to program to count occurences of each character?

    Need output like
    H - 1time,
    l -2 times ,etc..

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Loop through all the characters adding/updating their ferequencies in a Map.

  3. #3
    satheeshtech is offline Member
    Join Date
    Jul 2009
    Posts
    18
    Rep Power
    0

    Default

    actually code should be generic.. means any string may come instead of "hello"..
    can u provide me code example pls

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Read my response again carefully, try some code yourself and post if you get problems with your code.

Similar Threads

  1. How to count charectors in string?
    By satheeshtech in forum Advanced Java
    Replies: 12
    Last Post: 01-09-2010, 03:23 PM
  2. How to use a timer to count up or down.
    By caryr in forum AWT / Swing
    Replies: 5
    Last Post: 06-28-2009, 08:33 PM
  3. Replies: 8
    Last Post: 02-04-2009, 08:55 PM
  4. Replies: 2
    Last Post: 05-04-2008, 10:52 PM
  5. Getting row count
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-11-2008, 08:49 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •