Hello perhaps you could help me with a problem please.
I wish to display a table of results using a JTable. Customarily I use a 2D Object array which is initialized with the data in a manner as follows:
public Object[][] data={
{"Biology",25},{"Additional Math", 54},{"Geography",43},{"History",21},{"Spanish", 47},
{"Information Tech.",110},{"Technical Drawing",54},{"French",45},{"Physics",76},{"Chemistry",76},
{"Principles of Accounts",34},{"Principles of Business",30}
};
However this time, initialising won't work because the data that I am receiving will be subject to change, thus the 2D array needs to be created at a later point.
The added data that I will be receiving, will come from two(2) arrays, one containing Strings and the Other integers.
How would I go about filling my 2d Object array to get this done please?
My weak attempt
public Object[][] dataCreate(String[] subs, int[] tot, int max)
{
int i=0;
Object[][] data = null;
for(i=0;i< max; i++)
{
Object[] temp={subs[i],tot[i]};
data[i][0]=temp;
}
return data;
}