arraylist - Convert List of List into list in java -


list<list<string>> superlist = new arraylist<list<string>>();      list<string> list1 = new arraylist<string>();     list1.add("a1");     list1.add("a2");      list<string> list2 = new arraylist<string>();     list2.add("b1");     list2.add("b2");      list<string> list3= new arraylist<string>();     list3.add("c1");     list3.add("c2");       superlist.add(list1);     superlist.add(list2);     superlist.add(list3);      list<string> result= new arraylist<string>(); 

now want create new list contains values in superlist. here result should contain a1,a2,b1,b2,c1,c2

try using flatmap:

list<list<object>> list =  list<object> lst = list.stream()         .flatmap(x -> x.stream())         .collect(collectors.tolist()); 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -