Results 1 to 4 of 4

Thread: Strings

  1. #1
    Krazzyjman is offline Member
    Join Date
    Sep 2012
    Posts
    1
    Rep Power
    0

    Default Strings

    Hello everyone!
    I am new to Java and I am trying to learn it by myself along with taking a class for it.
    I have a question about strings
    I am trying to write a small program that takes two strings from using input (lets call them String a and String b) and compare them.
    An example of how I am trying to compare would be:
    String a= CATSATONTHEMAT String b= AT and I need to output to be how many times "AT" appears in String a
    Is that the string compare function? I have tried setting up a for loop with a counter, but was unsuccessful.
    I do not want someone to just give me code that works, just some suggestions that might help me get to the correct line of thinking.
    Any help would be awesome

    Thank you

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: Strings

    Please go through the Forum Rules -- particularly the third paragraph.

    Also see Guide For New Members and BB Code List - Java Programming Forum

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,785
    Blog Entries
    7
    Rep Power
    21

    Default Re: Strings

    You have to read the API documentation; (this link is for version 1.6; google for version 1.7). In the String API it suggests to use the indexOf( ... ) method.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default Re: Strings

    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. need help with strings
    By iron_fist in forum Java Applets
    Replies: 10
    Last Post: 02-15-2012, 06:16 PM
  2. Strings
    By leepikamukharji in forum New To Java
    Replies: 12
    Last Post: 04-18-2011, 02:43 PM
  3. Need help with Strings
    By </3java in forum New To Java
    Replies: 24
    Last Post: 02-17-2011, 06:00 PM
  4. Strings
    By zoala001 in forum Java Applets
    Replies: 9
    Last Post: 01-02-2011, 11:26 AM
  5. It is possible in Strings..?
    By mlibot in forum New To Java
    Replies: 1
    Last Post: 03-12-2010, 06:30 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
  •