Apex List Syntax
An Apex Collection is the in-memory store of data for code execution based on indexed order starting sequentially from 0 to X. Collection Types: Lists (Arrays), Maps, Sets. List Collection Collect elements or other collections. Collect anything from Integers, Strings, objects, user-defined types, built-in Apex types etc. In fact, a List collection can include a list of lists and therefore you gain a multi-dimensional view. Sequence is important in list with the first indexed position being 0. A list can have duplicates. Use new keyword to create a list. “new” needs to follow by the element type being collected which are held in < >.
List Example:
List <Account> sObjectAccountVariable = new List <Account>();
What the above code does is it creates a List of <accounts> where the sObjectAccountVariable is a user-defined name to be referenced later on by some code when the new List of <Account> is needed.











