Results 1 to 3 of 3
  1. #1
    laxbro is offline Member
    Join Date
    Jan 2013
    Rep Power

    Default Letter Frequency

    I need help creating a letter frequency method. I can't figure it out. I need a simple way. I've searched and most of the them use char and other stuffe I haven't learned yet. I only know basic stuff like for loops, int[], string[], if, else, .indexOf, compareto, .equals, and other basic stuff
    this is the code given to me
    Java Code:
    public static void letterFreqeuncy(String s) {
    Last edited by laxbro; 01-21-2013 at 10:19 PM.

  2. #2
    J-max04 is offline Member
    Join Date
    May 2012
    Rep Power

    Default Re: Letter Frequency

    Using Chars is easy, but if you really dont want to you cant get an array of strings of the letters like this.
    Java Code:
    String[] letters = new String[s.length()];
    for(int i = 0; i < s.length(); i++)
        letters[i] = "" + s.charAt(i);
    Then you can probably figure out the rest.
    But if you want to learn chars just follow this link: Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language Basics)

  3. #3
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Rep Power

    Default Re: Letter Frequency

    @J-max04: s.toCharArray() does the same and it doesn't reall help.

    @laxbro: How would you do it with a pencil and paper? You know everything to do solve this.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

Similar Threads

  1. Sound Frequency
    By MemoNick in forum New To Java
    Replies: 10
    Last Post: 11-05-2011, 10:29 PM
  2. frequency of occurence of a letter in a string
    By manish007g in forum New To Java
    Replies: 4
    Last Post: 06-23-2011, 09:05 PM
  3. Sort Frequency
    By ScaryJello in forum New To Java
    Replies: 7
    Last Post: 03-26-2009, 12:47 AM
  4. Word Frequency
    By capu in forum Advanced Java
    Replies: 2
    Last Post: 10-09-2008, 02:03 PM
  5. Frequency Counter
    By justlearning in forum New To Java
    Replies: 0
    Last Post: 05-07-2008, 10:50 PM

Posting Permissions

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