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
ifthikar Ahmed 1ifthikar Ahmed 1 

pls clarify

Hi..
i am new to salesforce ,

in visual force , while using controller to get the object fields from an object 2 typs of methods are used 
1.
public Account getAccount() {
       return account; 
  }

2.
public Account account { get; private set; }
does they both do the same job and which place we hv to go with the 1st method and for which place do we have to go with 2nd  , pls explain
 
Best Answer chosen by ifthikar Ahmed 1
ifthikar Ahmed 1ifthikar Ahmed 1
i did a bit of search and below vidio clarified all my answers
Link: https://youtu.be/J3SNz1DPoAM

All Answers

Sunil RathoreSunil Rathore
Hi Iftikhar,

Please refer the below link. This will help you to clear all your doubts.
http://www.forcetree.com/2009/07/getter-and-setter-methods-what-are-they.html

Hope this will help you. If does, then mark it as the best answer so it can also help others in the future.

Many Thanks,
Sunil Rathore
ifthikar Ahmed 1ifthikar Ahmed 1
@Sunil Rathore
Thank you 
it does help yet i am not getting a clear picture, 
Deepali KulshresthaDeepali Kulshrestha
Hi ifthikar,

Get and Set are properties to read and write the values respectively. To set their accessibility within or outside of the class, 
we use private, public, protected access modifiers.

Please go through below links to analyse difference between them.It may be helpful for you. 

Link: http://www.sfdcpanda.com/getter-and-setter-methods-in-salesforce/
Link: https://developer.salesforce.com/forums/?id=906F0000000Au38IAC
Link: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_controller_getter_methods.htm

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
www.kdeepali.com
ifthikar Ahmed 1ifthikar Ahmed 1
i did a bit of search and below vidio clarified all my answers
Link: https://youtu.be/J3SNz1DPoAM
This was selected as the best answer