Results 1 to 3 of 3
  1. #1
    zoe
    zoe is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    Default Analyze a string of words

    Hi, I'm coding a small GUI app that analyze a string of words.
    It counts the number of words and the longest words length.
    I'm currently using indexOf() and substring() methods to find the first word in the string, but I am lost on how to get the second words and so on extracted.
    Any ideas for this?
    Thanks.

  2. #2
    Seemster is offline Member
    Join Date
    Jul 2007
    Posts
    55
    Rep Power
    0

    Default

    were are the strings coming from? is this provided via console or some other program. need more information to help you out.

  3. #3
    shanePreater is offline Member
    Join Date
    Jul 2007
    Location
    England, Bath
    Posts
    47
    Rep Power
    0

    Default

    The simplest way would be to store the un-tokenised string of words in a string then use the split(" "); method of String to get an array of the words this then allows you to loop the array looking for the longest and also provides the word count as this is the array size.

    Hope this helps matey.

Similar Threads

  1. Replies: 4
    Last Post: 07-07-2008, 01:32 PM
  2. The words *game* in java programming :confused:
    By ibmzz in forum Advanced Java
    Replies: 1
    Last Post: 01-23-2008, 09:23 AM
  3. help w words
    By Gilgamesh in forum New To Java
    Replies: 5
    Last Post: 11-21-2007, 06:15 PM
  4. program help: Extracting words from a string
    By toad in forum New To Java
    Replies: 1
    Last Post: 11-04-2007, 06:39 PM
  5. Aspose.Words for Java - 2.1.0.0
    By levent in forum Java Software
    Replies: 0
    Last Post: 05-24-2007, 10:08 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
  •