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
Yoshinori MoriYoshinori Mori 

List Type and Non-List Type

I simply don't understand the idea of the difference between List and Non-List type(simple Object(DB) type).

List<ABCobject__c> abc and ABCobject__c

Names are the same.

Both are to be used.

 

Please correct what I understand about the List and Non-List(object(DB) type)

 

1.List type is to store data with index.

2.List type is needed to do something  if or while statement  while storing all data into List type object?

   Do something from the all data?

3. Non-List is simply needed to access single data from the Non-List object.

 

Thanks

Mori  

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

A List is a collection of elements, while the non-list is a single instance of an sobject record.

 

When you store data in a list it not only has an index associated with it, but it is an ordered collection, which means that you get the elements out in the same order that you put them in.  You can also put duplicate elements into a list.

 

You'd use a list when you have more than one item of data (e.g. all the contacts that are associated with an account).  You'd use the non-list when you have a single item of data (e.g. the account).

 

There is also a special for loop syntax that allows you to iterate the contents of a list, but its really just a convenience shortcut, as you can iterate a list by incrementing an index.

 

 

All Answers

bob_buzzardbob_buzzard

A List is a collection of elements, while the non-list is a single instance of an sobject record.

 

When you store data in a list it not only has an index associated with it, but it is an ordered collection, which means that you get the elements out in the same order that you put them in.  You can also put duplicate elements into a list.

 

You'd use a list when you have more than one item of data (e.g. all the contacts that are associated with an account).  You'd use the non-list when you have a single item of data (e.g. the account).

 

There is also a special for loop syntax that allows you to iterate the contents of a list, but its really just a convenience shortcut, as you can iterate a list by incrementing an index.

 

 

This was selected as the best answer
Ram-SFRam-SF

List is the updated version of Array.

Group of same type(ABCobject__c) can able to stored in a List. Better you google it to know more!!!!!!

Yoshinori MoriYoshinori Mori

Thank you bob_buzzard

 

I've got a clear image of the List and Non-List Type.

 

Mori