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());
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter