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
harshadeepthi kharshadeepthi k 

difference between list<account> a = new list<account>(); and account a = new account();

Good Morning all,


I'm new to Apex, I want to know the difference between the following two statements regarding sObjects -
1. List<Account> a = new list<Account>();
2.Account a = new Account();
please explain me the difference.

 

Thanks in advance,
Harsha Deepthi

Best Answer chosen by harshadeepthi k
Team NubesEliteTeam NubesElite
Hi Harsha,
list<account> a = new list<account>();
Which means you are creating a list of accounts and the name of the list is a.
account a = new account();
The above one means you are creating one account to the account object.



Thank You
www.nubeselite.com

Developement | Training | Consulting

Please Mark this as solution if your problem resolved.

 

All Answers

Team NubesEliteTeam NubesElite
Hi Harsha,
list<account> a = new list<account>();
Which means you are creating a list of accounts and the name of the list is a.
account a = new account();
The above one means you are creating one account to the account object.



Thank You
www.nubeselite.com

Developement | Training | Consulting

Please Mark this as solution if your problem resolved.

 
This was selected as the best answer
harshadeepthi kharshadeepthi k

Hi NewBie,

 

Thank you for clearing my doubt.

 

Thanks & Regards,

Harsha Deepthi