Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Obtain string from certain index in a string array

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Obtain string from certain index in a string array

    Hi everyone. I'm new here and this is my first post. I am new to Java as you will see with my current "problem". I have a string array that contains about 10 strings. I know how to find the index of a particular string using but how do I find the string given at a certain index.
    For example:
    String[] strarray = { "duck", "goose", "games", "fun" };

    I want to find the string that is in index 3 of strarray (which would be "fun"). How can I achieve this?
    Thank you for any help.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,408
    Thanks
    49
    Thanked 2,214 Times in 2,187 Posts

    Default Re: Obtain string from certain index in a string array

    how do I find the string given at a certain index.
    You get access to the contents of an array element by using this syntax:
    arrayName[theIndex]

    See the tutorial:
    http://docs.oracle.com/javase/tutori...ts/arrays.html
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Jan 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Obtain string from certain index in a string array

    Yeah I just realized that... stupid me. Thank you.

Similar Threads

  1. [SOLVED] Which sort method to use for a String Array to output the index?
    By DANGEROUSSCION in forum Algorithms & Recursion
    Replies: 11
    Last Post: December 8th, 2012, 09:25 PM
  2. Testing if an inputted String exists in an String Array
    By djl1990 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 29th, 2012, 02:46 PM
  3. [SOLVED] Sorting an object array using string variables from a string array
    By Shadud in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 26th, 2012, 04:50 PM
  4. how to obtain the combination of ip in String??
    By sxlend in forum Java Networking
    Replies: 2
    Last Post: July 15th, 2012, 01:03 PM
  5. Replies: 1
    Last Post: February 4th, 2010, 03:23 PM