+ Start a Discussion

Please explain the below one

public list<Account> listAccount{ get; set; }
Best Answer chosen by praveen
Mahesh DMahesh D

All Answers

Amit Chaudhary 8Amit Chaudhary 8
listAccount is public List of account which can be used in VF page because getter and setter is available  get; set; }.

Getter Methods
Getter methods return values from a controller. Every value that is calculated by a controller and displayed in a page must have a corresponding getter method, including any Boolean variables. For example, in the sample page in Building a Custom Controller, the controller includes a getAccount method. This method allows the page markup to reference the account member variable in the controller class with {! } notation. The value parameter of the <apex:inputField> tag uses this notation to access the account, and dot notation to display the account's name. Getter methods must always be named getVariable

Setter Methods
Setter methods pass user-specified values from page markup to a controller. Any setter methods in a controller are automatically executed before any action methods.
For example, the following markup displays a page that implements basic search functionality for Leads. The associated controller includes getter and setter methods for the search box input, and then uses the search text to issue a SOSL query when the user clicks Go!. Although the markup doesn’t explicitly call the search text setter method, it executes before the doSearch action method when a user clicks the command button:

<apex:page controller="theController">
      <apex:pageBlock mode="edit" id="block">
               <apex:outputLabel for="searchText">Search Text</apex:outputLabel>
                  <apex:inputText id="searchText" value="{!searchText}"/>
                  <apex:commandButton value="Go!" action="{!doSearch}" 
                                      rerender="block" status="status"/>
        <apex:actionStatus id="status" startText="requesting..."/>
        <apex:pageBlockSection title="Results" id="results" columns="1">
           <apex:pageBlockTable value="{!results}" var="l" 
              <apex:column value="{!l.name}"/>
              <apex:column value="{!l.email}"/>
              <apex:column value="{!l.phone}"/>
public class theController {

    String searchText;
    List<Lead> results;

    public String getSearchText() {
        return searchText;

    public void setSearchText(String s) {
        searchText = s;

    public List<Lead> getResults() {
        return results;

    public PageReference doSearch() {
        results = (List<Lead>)[FIND :searchText RETURNING Lead(Name, Email, Phone)][0];
        return null;
Please check below post for more info

Let us know if this will help you
Mahesh DMahesh D
This was selected as the best answer
Thank you Mahesh it helped me. It clarified my doubt.
Thank you amit  for your reply and helped me.
Mahesh DMahesh D
Hi Praveen,

Please mark it as resolved, so that it will be helpful to others.