Results 1 to 2 of 2
  1. #1
    evanc is offline Member
    Join Date
    Dec 2011
    Posts
    1
    Rep Power
    0

    Default Arraylist to chararray

    Hello,
    I have tried multiple ways to do this but I cannot figure it out.

    I have a arraylist with each 'item' in the arraylist being a seperate string. What I want to do is to turn that arraylist into a 2-dimensional char array.

    For example, the arraylist has these two strings in it:
    qwerty
    asdfgh

    I want char[0][0] to be q; char[0][1] to be w; char[1][0] to be a; char[1][1] to be s;

    Or something with similar results to that...
    Anyone have any ideas?

    Thanks,
    Evan.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,453
    Blog Entries
    7
    Rep Power
    20

    Default Re: Arraylist to chararray

    Declare a String[][] with a row size equal to your List<String>.size(); fill in every row with the String.toCharArray() method. You'll probably get a 'ragged' array ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Replies: 12
    Last Post: 07-07-2011, 08:49 PM
  2. Replies: 7
    Last Post: 11-22-2010, 01:26 PM
  3. Change of index in charArray
    By kovalensue in forum New To Java
    Replies: 19
    Last Post: 11-10-2010, 11:34 AM
  4. Replies: 2
    Last Post: 04-21-2008, 11:43 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
  •