Results 1 to 2 of 2
  1. #1
    jschmall12 is offline Member
    Join Date
    Apr 2010
    Posts
    2
    Rep Power
    0

    Default create a 2d char array from a 1D string array

    I need to create a 2d char array from a 1D string array It will not let me do the toCharArray() method to convert it Can anyone give me some sample code to help me?

  2. #2
    m00nchile is offline Senior Member
    Join Date
    Feb 2010
    Location
    Ljubljana, Slovenia
    Posts
    470
    Rep Power
    5

    Default

    Java Code:
    String[] str = {"abc", "123", "woof", "blarg"};
    char[][] chr = new char[str.length][];
    for(int i = 0; i < str.length; i++)
      chr[i] = str[i].toCharArray();
    Ever seen a dog chase its tail? Now that's an infinite loop.

Similar Threads

  1. convert byte array into char array
    By kgkamaraj in forum New To Java
    Replies: 4
    Last Post: 09-13-2011, 12:32 PM
  2. how to store into array.char cannot dereference
    By dark_metal in forum New To Java
    Replies: 9
    Last Post: 04-05-2010, 08:40 PM
  3. array of char
    By sinisab in forum New To Java
    Replies: 9
    Last Post: 01-05-2010, 10:48 AM
  4. fill object of array with char
    By begginer12 in forum New To Java
    Replies: 1
    Last Post: 12-05-2009, 03:11 AM
  5. Convert Char Array to String Array
    By Mayur in forum New To Java
    Replies: 8
    Last Post: 10-12-2009, 12:41 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
  •