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
diydiy 

How to add a list value to templist?

How to add a list value to templist?

 

for eg:

 

list A - 10 rows value

templist .add(listA);

list A.clear();

list A - 7 rows value

templist .add(listA);

 

In o/p  = templist have 17 row values

angelabregoangelabrego

Something like this?:

 

List<String> listA = new List<String>{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'};
List<String> listTemp = new List<String>();

listTemp.addAll(listA);

//Assert Temp List has 10 items.
System.assertEquals(10, listTemp.size());

 

listA.clear();
listA.addAll(new List<String>{'K', 'L', 'M', 'N', 'O', 'P', 'Q'});
listTemp.addAll(listA);

//Assert Temp List has 17 items.
System.assertEquals(17, listTemp.size());