java - How to split element in an ArrayList in multidimensional arrayList -
i have following:
[[statistics (ph)], [ upright normal recumbent normal total]] i want split first element of second element on whitespace end with:
[[statistics (ph)], [upright,normal,recumbent,normal,total]] my code far:
for (arraylist<list<string>> row2 : statsph) { row2.get(1).get(0).split("\\s"); } but nothing happens
java strings are immutable, need store return value of split("\\s") in correct list.
i recommend like
for (arraylist<list<string>> row2 : statsph) { list<string> stats = row2.get(1); // remove() returns object removed string allstats = stats.remove(0); collections.addall(stats, allstats.split("\\s")); } note we're removing original string first, adding of 'split' values.
Comments
Post a Comment