Apex code typically contains many things that we might be familiar with from other programming languages.
1. Naming Variables Apex
Declaring variables:
You cannot use any of the Apex reserved keywords when naming variables, methods or classes, such as: list, for,...
2. SOQL Query Apex
This will be used to fetch the data from Salesforce database.
EX:
3. Loop Statement Apex
Apex supports the following types of loops:
+ Do-while
+ While
+ For
EX:
4. Conditional (if-else) Apex
EX:
Performs the records insert, update, upsert, delete operation on the records in database.
Ex:
Apex has the following types of collections:
+ Lists (arrays): A list is a collection of elements, such as Integers, Strings, objects, or other collections.
+ Maps: A map is a collection of key-value pairs. Keys can be any primitive data type. Values can include primitive data types, as well as objects and other collections.
+ Sets: A set is a collection of unique, unordered elements. It can contain primitive data types, such as String, Integer, Date, sObjects,...
1. Naming Variables Apex
Declaring variables:
datatype variable_name;OR:
datatype variable_name = value;EX:
Account objAcc = new Account();
List<Account>listAcc = new List <Account>();
You cannot use any of the Apex reserved keywords when naming variables, methods or classes, such as: list, for,...
2. SOQL Query Apex
This will be used to fetch the data from Salesforce database.
EX:
Select Id, name from Account
3. Loop Statement Apex
Apex supports the following types of loops:
+ Do-while
+ While
+ For
EX:
for (Integer i = 0; i < 10; i++) {
System.debug("SalesforceXQ");
}
4. Conditional (if-else) Apex
EX:
Integer i = 1;5. DML Statement Apex
if (i == 0) {
System.debug('Salesforce');
} else if (i == 1) {
System.debug('XQ');
} else {
System.debug('SalesforceXQ');
}
Performs the records insert, update, upsert, delete operation on the records in database.
Ex:
update listAccount6. Using Collections Apex
Apex has the following types of collections:
+ Lists (arrays): A list is a collection of elements, such as Integers, Strings, objects, or other collections.
List<Account> listAcc = new List<Account> ();
<Id, Account> mapAcc = new Map<Id, Account>(); Map
<String>setStr = new Set<String> Set ();


