ForceTree.com: Collections in Apex: List, Maps and Sets

PHOTO EMBED

Fri May 21 2021 14:13:05 GMT+0000 (Coordinated Universal Time)

Saved by @powercod35

List<Account> listsample = [Select Id,Name from Account limit 5];
system.debug('The Account Name at index 0 is'+listsample[0].Name);
system.debug('The size of the list is'+listsample.size());
//Adding a element to the list
listsample.add(new Account(Name='testlistsample'));
system.debug('The size of the list now is'+listsample.size());
//Remove a element from the list
listsample.remove(5);
system.debug('The size of the list now is'+listsample.size());
content_copyCOPY

https://www.forcetree.com/2013/05/collections-in-apex-list-maps-and-sets.html