Results 1 to 2 of 2
  1. #1
    phil128 is offline Member
    Join Date
    Sep 2008
    Posts
    40
    Rep Power
    0

    Default converting 1D array to 2D for JTable

    Hi. I've been practicing using JTable and i know it requires a 2D array object but is it possible to convert a string of 1D-arrays into a string of 2D-arrays? My personally solution to this might be compairing the start and end of each string element in the array[] then cycle through till the end and in the process copying each element into an array[][] being a 2D.

    Any thoughts on this?

  2. #2
    phil128 is offline Member
    Join Date
    Sep 2008
    Posts
    40
    Rep Power
    0

    Default

    Done it: Here's the code if anybody needs help

    int[] array1d = new int[10];
    int[][] array2d = new int[1][1];


    //1D

    for(int z=0; z<array1d.length; z++){

    array1d[z] = z;

    }

    //2D
    for(int x=0; x<array1d.length; x++){
    for(int a=0; a<array2d.length; a++){
    for(int b=0; b<array2d.length; b++){


    array2d[a][b] = array1d[x];

    System.out.println(array2d[a][b]);



    }
    }}

Similar Threads

  1. Converting ArrayList to Array
    By vasavi.singh in forum New To Java
    Replies: 1
    Last Post: 02-23-2009, 03:34 PM
  2. Converting a String into a array.
    By taraxgoesxboom in forum New To Java
    Replies: 12
    Last Post: 02-22-2009, 06:29 AM
  3. Converting an Array to a Vector
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-14-2008, 09:44 PM
  4. Converting a Collection to an Array
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-14-2008, 09:44 PM
  5. Converting ArrayList to Array
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-13-2007, 11:41 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
  •