Sunday, June 4, 2017

Apex - Class


Apex - Class

A class is a template or blueprint from which objects are created. An object is an instance of a class. This is standard definition of Class.

→ 3 ways to create apex class in salesforce
  1.   Apex Class
  2.  Apex from Developer Console
  3.  Force.com Eclipse IDE

    From Apex Class:

     Step 1: Click on Setup option. (Top right side on Org)

     Step 2: Search 'Apex Class' in Quick find box and click on Apex Classes link. It will open the Apex Class details page.

      



     Step 3: Click on 'New' button to create new Class.
          



     Step 4: Write code here and then click on save button.
     


From Developer Console:

    Step 1: Go to Name and click on Developer Console.
    Step 2: Click on File menu New and then click on Apex class.

    Step 3: Write Class name and click on OK button.

    Step 4: Write code here.



   From Force.com IDE:
     Step 1: Open Force.com – Eclipse.

    Step 2: Create a New project by clicking on File New Apex Class.

   
    Step 3: Write the Name of Class and click on Finish button.



    Step 4: Once this is done, the new class will be created.

  
    Syntax:
    private | public | global 
    [virtual | abstract | with sharing | without sharing] 
    class ClassName [implements InterfaceNameList] [extends ClassName] 
    { 
      // Classs Body
    }

    Example:

    public class Sampleclass
    {       
         public static Integer a1 = 0; 
         public static Integer getmultiValue()
        {
                 a1 = a1 * 10;
                 return a1;
        }
    }

   


2 comments:

  1. Good Article,
    Can you please add Lightning related article.

    ReplyDelete
    Replies
    1. Ya, Next article will be Salesforce Lightning.

      Delete