Skip to main content

Apex Data Types

Apex Data Types


Data types are used to store the different sizes and values that can be stored in a variable during execution of program.

Apex supports the following data types :

  1. Primitive (Integer, Double, Long, Date, Datetime, String, ID, or Boolean)
  2. sObject
  3. Classes and Interfaces
  4. Collections (Lists, Sets and Maps)

Integer :  
It is a 32-bit number without any decimal value . The value range for this data type starts from -2,147,483,648 and the maximum value go up to 2,147,483,647.

For Example ,

Integer varInt = 5;

String :  
It is used to store the text value. It does not have any limit for the number of characters. Here, the heap size will be used to determine the number of characters in Apex programming.

For Example ,

String varString = 'CorpoVision Technology';

Boolean :  
This variable can either be false, true or null. In programming many times, this type of variable can be used as flag to identify if the particular condition is set or not set.

For Example ,

Boolean varTrue = true;  Boolean varFalse = false;
Long :  
This is a 64-bit number without any decimal point. This is used when we need a range of values wider than integer.

For Example ,

Long varLong = 50;

Decimal :  
A number that includes a decimal point. Decimal is an arbitrary precision number. In Apex Programming, generally Currency field's value is assigned to Decimal variable.

For Example ,

Decimal varDecimal = 12.34;

Double :  
This is a 64-bit number with a decimal point. This is used when we need a range of values wider than decimal.

For Example ,

Double varDouble = 12.3456;

ID :  
It is used to specify the valid 18-digit record id.

For Example ,

ID recordId = '0015g00000OxnO7AAJ';

Date :  
This datatype is used to store the date value only. It does not store the time along with date.

For Example ,

Date varCurrentDate  = Date.today();

DateTime :  
This datatype is used to store the date-time value. It also stores the time along with date.

For Example ,

 DateTime varCurrentDateTime = DateTime.now();

Time :  
This datatype is used to store the time value only. It does not store the date along with time.

For Example ,

Time varCurrentTime = DateTime.now().time();


By : Harshal Lad

Comments

Popular posts from this blog

Salesforce Development Index

C ourse C ontent Declarative Features Vs Programmatic Features Salesforce Architecture ( MVC ) Data Types Apex Classes If – Conditional and loops Collections in APEX List Set Map Oops Concepts Inheritance Polymorphism Encapsulation Abstraction Data Manipulation Language (SOQL) & SOSL Exception Handling Triggers and its Best Practices Custom Setting, Custom Metadata and Custom Labels Where to use it ? How to use it ? Apex Trigger + Custom Setting Asynchronous Apex Batch Classes Scheduler Classes Queueable Classes Future Method Apex Governor Limits Test Classes for Triggers and Apex classes Visualforce Pages Standard Controllers Extension Controllers Custom Controllers Wrappers Classes in Apex By : Harshal Lad ( CorpoVision Te

Opportunities at Paidwork Company

Unveiling the Potential of Paidwork Company : Unlocking Earning Methods, Referral Programs, and Achievements In the ever-evolving landscape of remote work and freelancing, Paidwork has emerged as a noteworthy platform that not only offers a diverse range of earning methods but also provides users with unique opportunities for growth and recognition. This article will delve into the intricacies of Paidwork, exploring its earning methods, referral program, and the benefits of achieving milestones on the platform. Go to Paidwork Website 1. Earning Methods on Paidwork: Paidwork provides freelancers and remote workers with various avenues to earn money, catering to a wide range of skills and expertise. The primary earning methods on Paidwork include: a. Freelance Projects: Users can browse through a plethora of freelance projects posted on Paidwork. From graphic design and content creation to software development and digital marketing, the platform hosts diverse opportunities for indi

Apex Triggers and Classes

  Apex Triggers   is use to execute the functionality or piece of code on record manipulation ( i.e., CREATE / UPDATE / DELETE / UNDELETE   records ). A trigger executes before and after an event occurs on record.