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
Kartik BhallaKartik Bhalla 

What is a wrapper class and how to use it and when to use it. plz helppp

I am not able to understand from any of the articles on the internet. plz can any one explain the syntax and with example like I am getting confused why and when do we use contructor in wrapper class and can we write wrapper class without constructor, what exactly the wrapper class returns.. an object? or list of objects?  Please any can explain me with an easy practical example covering everything.. it will be really helpful. I have to use it in my aura component

 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Karthik,

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.

Using Wrapper classes we can have the ability to check few records from the displayed list and process them for some action. 

Please find the below article for details of the wrapper class.

https://www.forcetalks.com/blog/what-is-wrapper-class-in-salesforce-everything-you-need-to-know/

If this solution helps, Please mark it as best answer.

Thanks,