Results 1 to 5 of 5
  1. #1
    manish007g is offline Member
    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0

    Default frequency of occurence of a letter in a string

    please help!!!!
    give me some good logic to count occurence of different letters in a array ...

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    manish007g is offline Member
    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0

    Default

    bt how can i run a loop for A to Z since its not working with ascii codes

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by manish007g View Post
    bt how can i run a loop for A to Z since its not working with ascii codes
    You wouldn't. You'd loop through the char's found in the String. You could have an int array that represents your 'A' through 'Z' and if an 'a' or 'A' is encountered in the String increment your 0th array element by one. Note that you can do arithmetic on characters. So 'B' - 'A' equals 1, and 'C' - 'A' equals 2. Just be sure to get your case right.

  5. #5
    manish007g is offline Member
    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0

Similar Threads

  1. Counting occurence of a word in file
    By KAS in forum New To Java
    Replies: 15
    Last Post: 05-16-2011, 07:47 PM
  2. Replies: 5
    Last Post: 10-30-2010, 07:56 PM
  3. Searching the first occurence
    By The Hawk in forum New To Java
    Replies: 7
    Last Post: 11-29-2009, 01:36 PM
  4. Replies: 18
    Last Post: 07-12-2009, 06:47 PM
  5. Replies: 20
    Last Post: 05-14-2008, 10:42 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
  •