APEX FUNDAMENTALS
Data type :
2. Collections
3. Enums
1. Primitive data type :
These are the data types which are predefined by the Apex.- A primitive data types such as an Integer, Double, Long, Date, Date Time, String, ID or Boolean
- All primitive data types are passed by value, not by reference.
- All apex variable, whether they are class member variable, are initialised to null. Make sure that we initialise variable to an appropriate value before using them.
Apex primitive datatype include:-
Boolean:
- A value that can only be assigned true, false or null.
Date:
- A value that indicates a particular day date values contain no information about time. Date value must always be created with a system static method.
- Ex: Date myDate = Date.newinstance (2013,05,15);
- Output is 2012-05-15 00:00:00
Time and DateTime :
Each of these classes has a newInstance method with which we can construct a particular date and time values.
The Date and Time classes also have instance methods for converting from one format to another :
We can also manipulate the values by using a range of instance methods :
Example 1 :
Example 2 :
To define an Apex Class specify the following :
- Ex: Time t1 = newInstance(19,20,1,20);
- Output is 19:20:01
We can also create dates and times from the current clock :
- Date my = Datetime.now();
- Date t = Date.today();
The Date and Time classes also have instance methods for converting from one format to another :
- Ex: Time t2 = Datetime.now().time();
We can also manipulate the values by using a range of instance methods :
- Ex: Date t3 = Date.today(0);
- Date Next = t3.addDays(30);
2013-05-15 00:00:00
2013-06-16 00:00:00
2013-06-16 00:00:00
Integer, Long, Double and Decimal :
- To store numeric values in a variable, declare variables variable with one of the numeric data types. Integer, Long, Double and Decimal.
Integer:
- A 32-bit number that doesn’t include a decimal point Integer have a minimum value of -2, 147, 467, 678 and a maximum value of 2,147, 483, 647.
Ex: Integer i = 1;
Class :
A class is a collection of data members and methods.Example 1 :
=============================================
Class student
{
Integer no; //======These are data members of class
String name; //=====
{
Integer no; //======These are data members of class
String name; //=====
public void getDetails() //==== This is the method of the class
{
system.debug(‘roll no’ + no);
system.debug(’name’ + name);
}
}
{
system.debug(‘roll no’ + no);
system.debug(’name’ + name);
}
}
=============================================
Example 2 :
=============================================
Class Employee
{
Integer exp; //===== variable /data members of the class
String department; //=====
{
Integer exp; //===== variable /data members of the class
String department; //=====
void show() //===== Method of the class
{
//Write the logic here
}
}
{
//Write the logic here
}
}
=============================================
1. Access Modifiers :
- You must use one of the access modifiers for top-level class (Public or Global).
- You do not have to use access modifiers in the declaration of inner classes.
3. Required: The keyword class followed by the class name.
4.Optional extensions : AND / OR implementation.
Syntax :
=============================================
private | public | global [virtual | abstract | with sharing | (none)]
Class ClassName [implements InterfaceNameList | (none)] [extends ClassName | (none)]
{
// The body of a class
}
// The body of a class
}
=============================================
These are the basic fundamentals of the apex, In the next episode, we will discuss sharing and without sharing in salesforce.
WOHOOO !! YOU HAVE JUST COMPLETED APEX FUNDAMETALS EPISODE
If you like this salesforcekid learning platform please let me know in the Comment section...Also, Share with your salesforce folks wish you
Happy learning ☁️⚡️ (Learn. Help. Share.)
<< PREVIOUS NEXT >>
These are the basic fundamentals of the apex, In the next episode, we will discuss sharing and without sharing in salesforce.
WOHOOO !! YOU HAVE JUST COMPLETED APEX FUNDAMETALS EPISODE
If you like this salesforcekid learning platform please let me know in the Comment section...Also, Share with your salesforce folks wish you
Happy learning ☁️⚡️ (Learn. Help. Share.)
<< PREVIOUS NEXT >>
APEX FUNDAMENTALS
Reviewed by
on
Rating:
Date my = Datetime.now();
ReplyDeletechange Datetime to Date