Apex Controll statements

6 minute read
0
Sfdcpandaschool

Apex If-else Statement

The Apex if statement is used to test the condition. It always checks boolean condition: true or false. There are various ways of if statement in Apex.
Here, we are going to study the basic and advanced structure of decision-making and conditional statements in Apex. Decision-making is necessary to control the flow of execution when certain condition is met or not. Following diagram depicts the general form of a typical decision-making structure found in most of the programming languages

  • if statement
  • o An if statement consists of a Boolean expression followed by one or more statements as per requirements.

  • if-else statement
  • o An if statement can be followed by an optional else statement, which executes whenever specified Boolean expression is false.

  • if-else-if ladder
  • o An if statement can be followed by an optional else if as well as else statement, which is very useful to test multiple conditions using single if..else if statement..

  • nested if statement
  • o You can use one if or else if statement inside another if or else if statement(s) as per your requirements.

Post a Comment

0Comments
Post a Comment (0)