Results 1 to 4 of 4
Like Tree2Likes
  • 1 Post By tnrh1
  • 1 Post By pbrockway2

Thread: Finding Character at a Certain Index in a String?

  1. #1
    Yaviel is offline Member
    Join Date
    Feb 2012
    Posts
    2
    Rep Power
    0

    Question Finding Character at a Certain Index in a String?

    To get the index of a character in a string, I know to use the indexOf() method. But what if you want to do the reverse- find what character is at a prespecified index in a string?

    I'm sure I'm missing some overly obvious method, but I don't know what.
    Further example for clarification:

    String str = "This is a test.";
    //and then some method that would check, for example, to see if index(0) of this method was a "T" or not. It would return true if so, false if not.


    Thank you so much for your help!!

  2. #2
    tnrh1 is offline Senior Member
    Join Date
    Aug 2011
    Posts
    251
    Rep Power
    3

    Default Re: Finding Character at a Certain Index in a String?

    charAt(int index) method is the one you are looking for.
    pbrockway2 likes this.

  3. #3
    Yaviel is offline Member
    Join Date
    Feb 2012
    Posts
    2
    Rep Power
    0

    Talking Re: Finding Character at a Certain Index in a String?

    Thank you so much :) :) :) :) :) Awesome poeple like you make my day :D

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default Re: Finding Character at a Certain Index in a String?

    Also I recommend the Java Secret Tips and Tricks website. I have a link on my desktop and have it open whenever I code.
    DarrylBurke likes this.

Similar Threads

  1. Replies: 1
    Last Post: 10-09-2011, 06:57 PM
  2. Finding maximum number at index position
    By Shyamz1 in forum New To Java
    Replies: 9
    Last Post: 10-27-2010, 08:14 PM
  3. find index of string in another string
    By Sdannenberg3 in forum New To Java
    Replies: 4
    Last Post: 03-04-2010, 10:14 AM
  4. Replies: 1
    Last Post: 02-05-2010, 10:41 AM
  5. Finding the character set of a FILE
    By javaplus in forum Advanced Java
    Replies: 1
    Last Post: 01-22-2008, 06:36 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
  •