Results 1 to 4 of 4

Thread: Strings

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

    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
    Madgaon, Goa, India
    Rep Power

    Default Re: Strings

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

    Also see and BB Code List - Java Programming Forum

    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
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    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,

    Build a wall around Donald Trump; I'll pay for it.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

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