I'm doing a very basic Java GUI app. but I don't know what I'm doing wrong in here.
This is what I have done so far:
String[] colNames = { "QTY", "Item Code", "Amount" };
model = new DefaultTableModel(colNames, 0);
JTable table = new JTable(model);
String[] arrQty = {"2", "3", "10"};
String[] arrItemCode = {"Item 1", "Item 2", "Item 3"};
String[] arrAmount = {"100", "200", "80"};
String f_qty, f_itemcode, f_amount;
for(String arrAmt: arrAmount){
f_amount = arrAmt;
}
for(String arrQt : arrQty){
f_qty = arrQt;
}
for(String arrItem : arrItemCode){
f_itemcode = arrItem;
}
model.addRow(new Object[]{ f_qty, f_itemcode, f_amount });
But it won't allow me because compiler needs to initialize first the strings, how can I fix this issue? Any ideas?
