In this video, we will see Apex Control Structures Part 1 : Introduction | Salesforce Development.
Control Structures in Apex
è
These are the structures in programming languages which control the flow
of execution of statements.
Types of Control Structures
1. Sequence Structure
2. Selection Structure
3. Loop Structure
1. Sequence Structure
e.g.
integer a=3, b=4;
integer c;
c=a+b;
system.debug('Addition:'+c);
2. Selection Structure
How is it implemented in Apex?
1. Simple if
2. If else
3. Nested if
4. Else if Ladder
How is it implemented in Apex?
By using switch when
3. Loop Structure
How is it implemented in Apex?
1. for
2. while
3. do while
These looping statements have three major components:
initialization,
(only once)
condition,
(in every iteration)
increment/decrement,
(in every iteration)
1. for
Syntax:
for(initialization
; condition ; increment/decrement)
{
/*statements*/
}
2. while
Syntax:
initialization
while(condition)
{
/*statements*/
increment/decrement
}
3. do
while
Syntax:
Initialization
do
{
/*statements*/
increment/decrement
}
while(condition);
No comments:
Post a Comment