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
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

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();

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

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


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())

List<Account> AccList=new List<Account>();
AccList=[select id from Account Limit 5];

Thanks And Regards ,
Suraj Tripathi.