02 · Variables, types and collections
Article lesson
25m
1 min read
Lists, Sets and Maps do ninety percent of the work in real Apex. Learn the three of them properly and the rest is syntax.
Strong types, few surprises
Every variable declares its type. Id is not a String (until it is), Decimal beats Double for money, and null is the value you will meet most often.
Map<Id, SObject> is the workhorse
Half of all bulk-safe Apex is 'build a map, look things up by Id'. We build three of them in this lesson so the shape becomes reflex.
Practice in your org
- Open your Developer Edition org and follow along step by step
- Change one thing at a time and note what happens
- When something breaks, read the error before searching for it