I have the following method:
public Object[][] getTableData(JTable table) {
DefaultTableModel dtm = (DefaultTableModel) table.getModel();
int nRow = dtm.getRowCount(), nCol = 3;
Object[][] tableData = new Object[nRow][nCol];
for (int i = 0; i < nRow; i++) {
tableData[i][0] = dtm.getValueAt(i, 5);
//System.out.print(tableData[i][0] + " ");
tableData[i][1] = dtm.getValueAt(i, 4);
//System.out.print(tableData[i][1] + " ");
tableData[i][2] = (dtm.getValueAt(i, 2)) + " " + `(dtm.getValueAt(i, 3));`
//System.out.print(tableData[i][2] + " ");
//System.out.println();
}
return tableData;
}
I also have the following method:
public Object[] head(JTable table) {
JTableHeader th = table.getTableHeader();
TableColumnModel tcm = th.getColumnModel();
Object[] headdata = new Object[3];
headdata[0] = tcm.getColumn(5).getHeaderValue();
headdata[1] = tcm.getColumn(4).getHeaderValue();
headdata[2] = tcm.getColumn(2).getHeaderValue();
//System.out.println(headdata[x]);
list = new ArrayList<>(Arrays.asList(headdata));//list refers to column names
//System.out.println(list.get(0) +" "+ list.get(1) +" " + list.get(2));
return headdata;
}
I want to combined the 2 methods into a single method however one return type is Object[] and another return type is Object[][]
How could i combine the methods so i bring back 2 return types and bring back return tableData and return headdata from the same method.
I am 2 years amateur experienced in Java.