Java - rewrite a List<List<String>> -


this question has answer here:

i want rewrite list<list<string>> new values.

im working tableview (javafx) , when reorder columns, datalist should updated/rewritten.

this how table data looks (for example here want exchange first secound column):enter image description here

at example want 1. column has data of scond, , 2. column has data of first...

i wrote code, doesnt work:

private observablelist<list<string>> fnldata; . . tmplistdata = new linkedlist<list<string>>(); tmplistdata.addall(fnldata); int = 0; (list<string> ls : fnldata){     int j = 0;     (string s : ls){          s = tmplistdata.get(i).get(colorder[j]);          j++;     }     i++; } 

im getting error:enter image description here

when move first time column,nothing happens new column order number correct. second time reorder column, error appears , column order number false...

little advice:

outer list rows, , inner list columns

fist columns in order = 0,1,2,3,4...

then when reorder columns, save new order in colorder(//=5,0,1,2,3,4)

what not work? list not changed? or view not updated?

if assume outer list represent rows , inner column-values , colorder list of integers containing colorder[0] = 1 means first column (number 0) displays values column 1, have someting this:

private observablelist<list<string>> fnldata;  tmplistdata = new linkedlist<list<string>>();  (list<string> row : fnldata){     list<string> newrow = new linkedlist<>();     (int col : colorder){         string value = row.get(col);         newrow.add(value);     }     tmplistdata.add(newrow); } 

update according comment

s never used , s valid in (!) loop, not change value in ls. change that:

... (list<string> ls : fnldata){         (int j=0;j<ls.size();j++){         ls.set(j, tmplistdata.get(i).get(colorder[j]));                 }     i++; } 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -