function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
VSK98VSK98 

convert list<list<Account>> into list<Account>

Hi All,

Can we convert List<List<Account>> into List<Account>.

Regards,
VSK98
Raj VakatiRaj Vakati
Yes .. Code is here
List<List<Account>> listoflistofAccount = new List<List<Account>>();

List<Contact> listOofAccount = new List<Contact>();
for(Integer i=0 ;i<listoflistofAccount.size();i++){
	listOofAccount.addAll(listoflistofAccount.get(i));
}

 
Ajay K DubediAjay K Dubedi
Hi VSK98,

Try this one

List<List<Acccount>> Accountlist = new List<List<Account>>();
integer listsize = Accountlist.size();

List<Acount> Accountlist2 = new List<Account>();

If(Accountlist!=null && Accountlist.size()>0)
  {
  for(integer i=0; i<listsize; i++)
   {
       Accountlist2.addAll(Accountlist.get(i));
   }
}
 

Thank You,
Ajay Dubedi