I am getting this error for List
List index out of Bound Exception:2060
Here my Total Size is 2063.
for(Integer j=total_size-Math.mod(total_size,list_size);j<total_size;j++)
{
ListWrap.add(wraplist.get(j));
}
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityI am getting this error for List
List index out of Bound Exception:2060
Here my Total Size is 2063.
for(Integer j=total_size-Math.mod(total_size,list_size);j<total_size;j++)
{
ListWrap.add(wraplist.get(j));
}
The implication is that you have a variable called total_size which is = 2063 but you are referring to a list which doesn't have that many members. So you are trying to retrieve a list entry which doesn't exist.
Perhaps your calculation of total_size is incorrect? Why not use wraplist.size()
?
Try amending the code as follows, the output will be informative.
System.debug('total_size = ' + total_size);
System.debug('wraplist size = ' + wraplist.size());
for(Integer j=total_size-Math.mod(total_size,list_size);j<total_size;j++)
{
ListWrap.add(wraplist.get(j));
}