function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CLKCLK 

Advantages of Using Standard Property in Apex which Refers to itSelf

Example :

 

Public Case MyCase

{

     get

     {

           if(MyCase == null)

                 MyCase = new Case(); // do your opertion   

            return MyCase;

     }

set{}

}

 

Explation - This Property is refering itself & it does not goes into Stack overflow.

If you try same thing into other technology platform, it will cause Stack overflow.

 

Advantage -

1)No need to use private member variable in tha class.

2)As in example shown, this property will get initialized when vf page or controller class refers it. Means we are taking care of memory use

3) Avoiding null pointer exception.