Hello, i'm having issues trying to sort out a multidimensional array for a JTable. However, before i pass my array to a JTable, i'd like to work out how to set it up properly and then System.out.println it on the command line so i can have a rough idea what the table will look like. Here's the code i've been playing with.
1. To set up the array (assuming colum size will always be 3, whilst row size depending on whatever database returns):
Object[][] data = new Object[rowSize][3];
for (int i=0; i<data.length; i++)
{
data[i][0] = theString;
data[i][1] = theInteger;
data[i][2] = theDouble;
}
2. To display it on the command line:
for (int row = 0; row < data.length; row++)
{
for (int col = 0; col < data.length[row].length; col++)
{
System.out.println(data[row][col] + "\t");
}
System.out.println();
}
When i try and run this i get a crazy response with the array not printing out right and simple repeating the code.
I'd like to see on the screen something like:
theString1 theInteger1 theDouble1
theString2 theInteger2 theDouble2
theString3 theInteger3 theDouble3
etc etc
If any one has any suggestions i would be most grateful i've been messing with this for days
Cheers!