0
I created an array with two values and wanted to put it in a table... with an insert button (insert several lines) 1-I declared the string line[] and the values below; 2- I thought a 'for each' would solve by adding a line (add.Row) to each pass. but not. 3-for testing, the Sout is ok. 4 as a result, it prints twice the first string "first line"
String[] linha = {"primeira linha", "segunda linha"};
for(String linhas : linha){
((DefaultTableModel) jTable.getModel()).addRow(linha);
System.out.println(linha);
}
to remove the lines, I did it here and solved; because it comes to "int" in "removeRow"
// limpar todas as linhas da tabela jTable
for(int i = jTable.getRowCount(); i>0 ; i--){
((DefaultTableModel) jTable.getModel()).removeRow(0);
}
Translate the question, Luke. Otherwise it will be closed
– Evilmaax
I’ve already noticed that in foreach I have to use the string "lines" but addRow asks for an Object array... so I don’t know how.
– Luke Negreiros
I tried this one too

String[] linha = {"primeira linha","segunda linha"};
 for (int i = 0 ; i<linha.length ; i++){
 ((DefaultTableModel) jTableListaObstaculos.getModel()).addRow(linha);
 }

– Luke Negreiros