Skip to content
StackDecode
IntermediateLesson 17 of 37

Apex basics

Salesforce's Java-like, strongly typed language.

apex
String name = 'Ada';
Integer count = 3;
Decimal price = 9.99;
Boolean ok = true;
Date today = Date.today();

List<String> names = new List<String>{'Ada', 'Alan'};
Set<Id> ids = new Set<Id>();
Map<Id, Account> byId = new Map<Id, Account>([SELECT Id, Name FROM Account LIMIT 10]);

for (String n : names) {
    System.debug(n);
}

Collections: List, Set, Map. sObjects represent records: Account a = new Account(Name = 'Acme');. Apex is case-insensitive, runs on Salesforce's servers, and every run is bound by governor limits. Run snippets in Anonymous Apex in the Developer Console.