Results 1 to 2 of 2

Thread: String help

  1. #1
    Username14 is offline Member
    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    Default String help

    In a program I'm writing, I'm accessing a url that is simply a list of numerical data and "-" in lines separated by commas, i.e.

    66-43-221, 5651-5546, ....
    66-43-221, 5641-5546, ....

    I know how to open the link, use arrays and commas as a splitter to reference various parts of the data, etc., but I'm having a problem. I want to store all of second values (i.e. the 5651-5546) in an array based on having a common first value (i.e. 66-43-221). However, I have no idea what code to use to say "while the first string in the array is the same" all the way down the list. It's not like I can go while (Array[0].equals(Array[0]). And I can't just write a while loop with .equals("the first number here") because the data sheet has various first values, not just one.

    Thanks for your help ahead of time.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,800
    Rep Power
    7

    Default Re: String help

    Quote Originally Posted by Username14 View Post
    In a program I'm writing, I'm accessing a url that is simply a list of numerical data and "-" in lines separated by commas, i.e.

    66-43-221, 5651-5546, ....
    66-43-221, 5641-5546, ....

    I know how to open the link, use arrays and commas as a splitter to reference various parts of the data, etc., but I'm having a problem. I want to store all of second values (i.e. the 5651-5546) in an array based on having a common first value (i.e. 66-43-221). However, I have no idea what code to use to say "while the first string in the array is the same" all the way down the list. It's not like I can go while (Array[0].equals(Array[0]). And I can't just write a while loop with .equals("the first number here") because the data sheet has various first values, not just one.

    Thanks for your help ahead of time.
    You could use a Map where the Key is the first number (66-43-221) and the Value would be a List of all the second numbers (5651-5546, 5641-5546, etc).

Similar Threads

  1. Replies: 3
    Last Post: 02-10-2012, 07:26 PM
  2. Replies: 1
    Last Post: 12-15-2011, 01:39 PM
  3. Replies: 12
    Last Post: 11-26-2010, 09:33 AM
  4. Replies: 1
    Last Post: 11-04-2010, 07:53 PM
  5. Replies: 0
    Last Post: 11-20-2007, 05:59 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •