Sunteți pe pagina 1din 11

Apex basics

Force.com Architecture
Data types & Variables
Coding basics
Primitive data types (Integer,
Boolean, String, etc.)

sObjects (sObject, or Account,


contact, object__c.)

Collection (list, set, map)


An object created from the user or
system-defined classes.
Variables coding basics

A primitive, such as an Integer, Double, Long, Date,


Datetime, String, ID, Boolean, among others.

An sObject, either as a generic sObject or as a specific


sObject, such as an Account, Contact, or
MyCustomObject__c (youll learn more about sObjects
in a later unit.)

A collection, including:
A list (or array) of primitives, sObjects, user defined
objects, objects created fromApexclasses, or
collections
A set of primitives

ApexCollections: List,
Set and Map

List<String> colors =newList<String>();

Set<String> Colors = new Set< String>();

Map<String, id> colors = new


Map<String, id>();
Apex Classes

Open the Developer Console by clickingYour Name|Developer


Console.
ApexCollections: List,
Set and Map
List is a ordered collection of values. It contains duplicate values. Each value is retrieved using the List Index
List<String> temp = new List<String>();
temp.add('Newyork');
temp.add('Miami');
temp.add('Boston');

Set:
Set is an unordered collection of values. It does not contains duplicate values
Debugging Techniques

E.g. a list of String


List<String> lstNames = new List<String>();
lstNames.add('King'); // add is the way to add data to list
lstNames.add('Kong');

// you can retrive list entries as following


System.debug(lstNames[0]); // return King
System.debug(lstNames.get(1)); // return Kong

Debug Logs

Setup Debug Logs User


Inspect Debug Logs
Common Methods used in List

add(listElement)

add(index, listElement)
isEmpty()
remove(index)
sort()

size()
Common Methods used in Set
add(setElement)

contains(setElement)
equals(set2)
size()
remove(setElement)

Common Methods used in Map


clear()
equals(map2)
containsKey(key)
get(key)
isEmpty()
size()
remove(key)

S-ar putea să vă placă și