+ Start a Discussion
Ashok S 7Ashok S 7 

What is the size of the list

Hai Guys,
I want to know what is the size of list can any one tell me please
AshlekhAshlekh
Hi,

In class you can get the size of list by below code.
 
Public List<Account> myAccList{set;get;}
myAccList  = [select id from account];
Integer sizeOfList = myAccList.size();
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_list.htm

And in VFP
 
<apex:variable value="{!myAccList.size}" var="t"/>

-Thanks
Ashlekh Gera



 
Manish Pal 17Manish Pal 17

Method name :-  size()
(Returns the number of elements in the list)
Signature:- public Integer size()
Return Value Type:-  Integer

Example:-

List<Integer> myList = new List<Integer>();
Integer size = myList.size();
system.assertEquals(0, size);
 
List<Integer> myList2 = new Integer[6];
Integer size2 = myList2.size();
system.assertEquals(6, size2);
Suraj Tripathi 47Suraj Tripathi 47
Hi Ashok,
There is a standard function/method for getting the size of list(size())

Example:
List<Account> AccList=new List<Account>();
AccList.size();
AccList=[select id from Account Limit 5];
System.debug('AccList---->'+AccList.Size());

Thanks And Regards ,
Suraj Tripathi.