Store value in an ArrayList ArrayList

0

Hello, I have a question regarding storing the value I get from a table in an arraylist from arraylist. How should I do to store?

For example:

Private ArrayList<ArrayList<String>> valorMatriz = new ArrayList<ArrayList<String>>();

String v;

int linha = jTable2.getRowCount();
int coluna = jTable2.getColumnCount();

for(int i = 0; i < linha; i++){
  for(int j = 0; j< coluna; j++){
     valor = jTable2.getValueAt(i,j).toString();
    //código que armazena a variável valor em valorMatriz
     print(valor + " ");
  }
}

Question: What is the syntax for storing variable v in Matrix value?

    
asked by anonymous 21.07.2016 / 20:58

1 answer

2
ArrayList<ArrayList<String>> valorMatriz = new ArrayList<>();

String v;

int linha = jTable2.getRowCount();
int coluna = jTable2.getColumnCount();

for(int i = 0; i < linha; i++){
    ArrayList<String> arrayLinha = new ArrayList<>();
    for(int j = 0; j< coluna; j++){
        valor = jTable2.getValueAt(i,j).toString();
        arrayLinha.Add(valor);
        print(valor + " ");
    }
    valorMatriz.add(arrayLinha);
}
    
21.07.2016 / 22:01