简体   繁体   中英

How do I convert nested arraylist to an arraylist?

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} 

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()]);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM