Data Types in Apex Salesforce
Integers, long, double and decimal:
To store numeric values in variables with one of the numeric data types integer, long, double and decimal.
Integer: 32 -bit numbers that doesn’t include a decimal point.
Integers have a minimum value of -2,147,483,648 and a maximum of 2,147,483,647
Eg: integer i=1;
Long: a 64 t numbers that doesn’t include a decimal point longs have a minimum value of 263-1.
Eg: long l = 2147483648 L;
Double: A 64-bit number that includes decimal point. Doubles have a minimum value of -263 and a maximum value of 263-1.
Ex: double d = 3.14159;
Decimal: a number that includes a decimal point. Decimal is an arbitrary precision number, currency filed are automatically assigned the type decimal.
Ex: decimal dec =19.23;
Null variable: if we declare a variable and don’t initialize it with a value, it will be null, null means absence of a value we can also assign a null to any variable declared with a primitive type.
Both of these statements result in variable set null;
Boolean x is = null;
Decimal d;
String: strings are set of characters and are enclosed in a single quote. They store text value such has a name or and address.
Ex: date d1 =date today ();
String s = string value of (d1);
The o/p above example should be today’s date.2017-04-25.
Subject types:
A subject, can be generic subject or be a specific subject,Such has an account, contact, or my custom Subjects (short for “sales force objects”) are standard or custom objects that store record data in the force.com data base these is also a subject data type in apex that is the programmatic representation of these subjects and their data in code.
Developers refer to subjects and their fields for by their API names
Ex: Account a = new account ();
My custom object –c co = new my custom object—C ();
↕
API name of the custom object.
The following example creates an invoice statement with some initial value for the description –C, which is a subject type also.
Ex: invoice – statement –C, invoice - new invoice – statement—C
Description –C = ‘test invoice’, status—C= ’pending’)
Subject variables are initialized to null, but can be assigned a valid object reference with the new operator.
No comments:
Post a Comment