Apex Datatypes Overview

Miscellaneous 10 Mar , 2017  


As we know that Apex is strongly typed language so all variables will be initially declared as any of the following datatype. All variables will be initialised will null values initially. So being a programmer we should keep this in mind that we have to initialised these variable with something otherwise it will throw null exception when we will use it.

Apex supports the following data-types:

  • Primitive (Integer, Double, Long, Date, Datetime, String, ID, or Boolean)
  • Collections
    • Lists of primitive, sObject, User-defined Objects, Object created by apex class, or collections
    • Sets of primitive
    • Map from a primitive to primitive, sObject, or collections
  • sObject
  • a typed list of values also known as Enums
  • User defined Apex Classes/System-Suplied Apex Class, Objects and Interfaces

Now lets try one by one –

Any 32 bit number which does not include any decimal point. The value range is -2,147,483,648 and a maximum value of 2,147,483,647.

Integer value1 = 123;
system.debug('my values is '+value1);