How to add the elements in the class variable Object []?

advertisements

How to add the elements in Object[] class variable? I've arrayList object which contain DTO class data (row 125, columns 6). I would like to display the all data in JTable.

String[] columnNames = {"TEST CASE NUMBER", "NO OF EXECUTION", "TOTAL NO OF PASSED", "TOTAL NO OF FAILED", "FINAL RESULT", "DATE & TIME"};

DefaultTableModel model = new DefaultTableModel(columnNames, 0);  

for (Object item : arrayList) {
    Object[] row = new Object[6];

    how to add the element in row ...?

    model.addRow(row);
}
final JTable table = new JTable(model);


you can maintain an integer i and in loop you can do

row [i] = item ;

P.S you have to check null,length etc to avoid exceptions ...