Results 1 to 2 of 2
- 03-12-2009, 11:46 AM #1
Member
- Join Date
- Sep 2008
- Posts
- 40
- Rep Power
- 0
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?
- 03-12-2009, 12:08 PM #2
Member
- Join Date
- Sep 2008
- Posts
- 40
- Rep Power
- 0
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
-
Converting ArrayList to Array
By vasavi.singh in forum New To JavaReplies: 1Last Post: 02-23-2009, 02:34 PM -
Converting a String into a array.
By taraxgoesxboom in forum New To JavaReplies: 12Last Post: 02-22-2009, 05:29 AM -
Converting an Array to a Vector
By Java Tip in forum java.langReplies: 0Last Post: 04-14-2008, 08:44 PM -
Converting a Collection to an Array
By Java Tip in forum java.langReplies: 0Last Post: 04-14-2008, 08:44 PM -
Converting ArrayList to Array
By Java Tip in forum Java TipReplies: 0Last Post: 11-13-2007, 10:41 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks