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.


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

Results 1 to 2 of 2

Thread: Easy array question

  1. #1
    Junior Member
    Join Date
    Jan 2011
    Thanked 0 Times in 0 Posts

    Default Easy array question

    Lets say i currently have a character array...{1, 0, 1, 0, 1, 0, 0, 1}

    How can i convert the first four elements of that character array into the first element of a string array?

    This is what I'm looking for:

    String[] number = new String[2];
    number[0] = "1010"


    Lets say i have a string "10101001"

    how can i convert this to a string array:
    number[0] = "1010"
    number[1] = "1001"
    Last edited by surfbumb; February 3rd, 2011 at 08:56 PM.

  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Thanked 833 Times in 772 Posts
    Blog Entries

    Default Re: Easy array question

    You can do this in a number of ways. If you have a defined length for each string, loop through the array and use a StringBuilder or StringBuffer, appending the array values until the string is long enough, at which point you can do what you wish with the resulting String that you retrieve from the Builder/Buffer

Similar Threads

  1. Quick easy Java question.
    By DHG in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 25th, 2011, 03:59 PM
  2. [SOLVED] Begginer Question please help ASAP! (Easy to Answer)
    By Bagzli in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 11th, 2010, 10:00 PM
  3. Easy help but can't figure it out.
    By weezer562 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: October 19th, 2010, 09:50 PM
  4. 2D Array Question
    By gmorris1986 in forum Java Theory & Questions
    Replies: 2
    Last Post: June 18th, 2010, 11:40 AM
  5. A question about an array
    By faizana2006 in forum Collections and Generics
    Replies: 2
    Last Post: October 28th, 2009, 04:36 PM