Apex - Primitive Data
types
-
Integer
-
Decimal
-
Double
-
Long
-
Date
-
Datetime
-
String
-
ID
- Boolean
1.
Integer
→ 32-bit number without
include decimal point.
→ Ex:
Integer intNumber = 70;
system.debug('Value of intNumber variable
-> '+ intnumber);
2.
Decimal
→ A number that includes
a decimal point.
→ Decimal is an
arbitrary precision number.
→ Currency fields are
automatically assigned the type Decimal.
3.
Double
→ 64 - bit number that
includes a decimal point.
→ Ex:
double pi = 3.14159;
system.debug('Value of
pi variable -> '+ pi);
4.
Long
→ 64 - bit number that does not include a decimal
point.
→ Longs have a minimum
value of -263 and a maximum value of 263-1.
→ Use this data type
when you need a range of values wider than the range provided by Integer.
→ Ex:
Long ln = 214748985683648L;
system.debug('Value of
long variable -> '+ ln);
5.
Date
→ A value that indicates a
particular day.
→ Date values not
contain information about time.
→ Ex:
Date dtDate =
date.today();
System.debug('Today
Date -> '+dtDate);
6.
Datetime
→ A value that indicates a particular day and
time, such as a timestamp.
7.
String
→ Set of meaningful characters surrounded by
single quotes.
→ It does not have limit on the number of
characters they can include.
→ Instead, the heap size limit is used to ensure
that your Apex programs don't grow too large.
→ Strings can be manipulated with several standard methods.
→ Ex:
String specialStr =
'The quick brown fox jumped over the lazy dog.';
System.debug('Special
string -> ' + specialStr);
8.
ID
→ Any valid 18-character Force.com record
identifier.
→ If you set ID to a 15-character value, Apex
converts the value to its 18-character representation.
→ Ex:
ID id='00300000003T2PGAA0';
9.
Boolean
→ A value that can only be assigned true, false,
or null.
→ This type of variables can be used as flag in programming
to identify the particular condition set or not set.
→ Ex:
Boolean youCan = true;
Thank you Nikhil
ReplyDelete