Salesforce Free Developer >

Chapter 2 - Apex Datatypes and Operators >

Operators in APEX

Operators in APEX

Types of Operators

1. Add/Sub:

  • If X and Y are integers or doubles then add or subtract the value of Y from X and if any X or Y is double then the result is double.
  • If X is a date and Y is an integer then it returns a new date that is incremented or decremented by the specified number of days.
  • If X s a DateTime and Y is an integer or double then it returns a new DateTime which is incremented or decremented by a specified number of days with a fractional portion corresponding to a portion of the day.

Ex: main() {

Double d = 5.2;

DateTime dt = new DateTime.now();

DateTime finalDate = dt -d ;

System.debug(dt);

System.debug(finalDate);

}

Note: Only in the case of ‘+’ if X is a string and Y is a string or any other type of non-null argument then it concatenates Y to the end of X.

 

Cyntexa CTA

 

 

 

Download Study Material

Get access to exclusive study material for Salesforce Certification and ace your exams!

Our Salesforce Certification Courses

Hey there! Glad you made it through our Salesforce Developer Training for beginners. But wait! We've got some high-in-demand Salesforce courses for you to take your Salesforce skills to the next level, making you a desired professional in the Salesforce job market.

Post a Comment

Your email address will not be published. Required fields are marked *