I had to turn nested ArrayList
List<List<TockaXY>> clustersPorazdeljeni = new ArrayList<>(center.size())
in to Array, witch with help of nice people from this site is now clear:
TockaXY[] arrayOfClusters = clustersPorazdeljeni.stream().flatMap(Collection::stream).toArray(TockaXY[]::new);
But I have to also do the reverse. So how to get from arrayOfClusters back an nested ArrayList like
List<List<TockaXY>> newClustersPorazdeljeni
?
[[foo1,foo2],[foo3]]or[[foo1],[foo2,foo3]]after turning them into 1 dimensional array you will get[foo1, foo2, foo3]from both of them, so we can't simply turn such array back into original list because we don't have any way to determine which version of nested list was used to create that array.