How do I convert nested arraylist to an arraylist?

84 Views Asked by At

I have stored HashMap into an ArrayList and now I want each position of ArrayList in different array so please can somebody tell me how it is possible?

My array list is like this:

{key:value, key:value, key:value, key:value}, 
{key:value, key:value, key:value, key:value}, 
{key:value, key:value, key:value, key:value} 
1

There are 1 best solutions below

1
Gaurav Gupta On

Assuming the map contains String as key and value. In case different replace datatypes. You can achieve this by:

Entry<String, String>[] array = list.get(0).entrySet().stream().collect(Collectors.toList()).toArray((Map.Entry<String, String>[])new Map.Entry [list.size()]);