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 ();
0 nhận xét:
Post a Comment