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
Bhupathi YadavBhupathi Yadav 

Wrapper class_example

public class wrapper_on_account
{
   List<wrapperaccount1> wrapaccount=new List<wrapperaccount1>();
   List<account> selectedaccountlst=new  List<account>();
    public List<wrapperaccount1> getAccounts()
    {
        for(Account a :[select Id, Name, AccountNumber, Phone from Account limit 5])
           wrapaccount.add(new wrapperaccount1(a));{I need Explination for this line}
         //How it works
          return wrapaccount;
         
    }
Amit Chaudhary 8Amit Chaudhary 8
Please check comment inline
public class wrapper_on_account
{
   List<wrapperaccount1> wrapaccount=new List<wrapperaccount1>();
   List<account> selectedaccountlst=new  List<account>();
    public List<wrapperaccount1> getAccounts()
    {
        for(Account a :[select Id, Name, AccountNumber, Phone from Account limit 5])
        {
        // In this block we are getting 5 record and adding all 5 Account record one by one in wrapaccount List 
        // I hope wrapperaccount1 is wrapper class So you are creating object of wrapperaccount1 class and   
        // adding same in list.

           wrapaccount.add(new wrapperaccount1(a));
        } 
          return wrapaccount;
         
    }


Please check below post for Wrapper class demo
1) http://amitsalesforce.blogspot.com/2016/03/wrapper-class-in-salesforce-select-all.html

Problem :- 
How can I display a table of records with a check box and then process only the records that are selected?

Solution:- 
Wrapper class.

A wrapper or container class is a class, data structure, or an abstract data type whose instances are a collections of other objects.It is a custom object defined by Salesforce developer where he defines the properties of the wrapper class. Within Apex & Visualforce this can be extremely helpful to achieve many business scenarios within the Salesforce CRM software.

Please let us know if this will help you