Results 1 to 4 of 4
  1. #1
    tiyani is offline Member
    Join Date
    Aug 2009
    Posts
    2
    Rep Power
    0

    Default storing a string in an array

    I want to split the string called x and store split sections in an array

    String x = "+x1 -x2 +x3";// where x1..xn represents numbers

    String [] temp ={"+x1","-x2","+x3"}; // the results

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    I have to admit that this confuses me a bit:
    Java Code:
    String x = "+x1 -x2 +x3";// where x1..xn represents numbers
    So, what is a typical String going to look like?
    How will you be receiving these Strings? From the command line? a text file? a GUI? a database?
    What have you tried so far and what is the result?
    What will you do with the String array once you have it?

    Much luck!

  3. #3
    Singing Boyo is offline Senior Member
    Join Date
    Mar 2009
    Posts
    552
    Rep Power
    6

    Default

    If you are getting input, try making the original string more like this...
    [code]
    string original = "x1;x2;x3;x4;x5;x6";
    [code]
    then using String.split(";") should return the array.
    Of course, you can substitute any character in place of the semi-colon (';')
    If the above doesn't make sense to you, ignore it, but remember it - might be useful!
    And if you just randomly taught yourself to program, well... you're just like me!

  4. #4
    tiyani is offline Member
    Join Date
    Aug 2009
    Posts
    2
    Rep Power
    0

Similar Threads

  1. storing strings into an array
    By anthonym2121 in forum New To Java
    Replies: 2
    Last Post: 04-04-2009, 08:32 AM
  2. String array to byte array?!
    By Joe2003 in forum Advanced Java
    Replies: 5
    Last Post: 02-28-2009, 07:09 AM
  3. Storing Array from HTTP Post
    By kskinner in forum New To Java
    Replies: 1
    Last Post: 09-08-2008, 07:00 AM
  4. String []Array
    By Warren in forum New To Java
    Replies: 4
    Last Post: 12-01-2007, 09:03 AM
  5. Replies: 1
    Last Post: 08-03-2007, 11:52 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
  •