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
Abilash.SAbilash.S 

Retrieved records by soql should save in a new list.

Soql query to get 100 records from account.
List<account> acctList = [select id, name from account limit 100]. The retrieved 100 records should save in NEW LIST. How could i accomplish.
Danish HodaDanish Hoda
List<account> newAcctList = new List<account>();
newAcctList.addAll(acctList);
CharuDuttCharuDutt
Hii Pavushetti Abhilash
Try Below Code
list<Account> list1 = new list<Account>();
list<Account> list2 = [select id,Name from Account];

list1.addAll(list2);
System.debug(list1);
Please Mark It As Best Answer If It Helps
Thank You!