You need to sign in to do that
Don't have an account?

How to add values to nested LISTs
Hi,
i am new to salesforce.
i have an doubt how to add values to the nested list
i have declared a nested list(as below) then i need to add values to that nested
List<List<Integer>> my_list_2 = new List<List<Integer>>();
Regards,
Bharath
All Answers
Thanks Damien,
But what is the difference between normal list and nested list
In both cases, we are adding single value means for nested i thought value like (i,j)
when i executed below code only differnce is DEBUG| (5) and DEBUG| ((5))
List<List<Integer>> my_list_2 = new List<List<Integer>>();
List<Integer> tempList = new List<Integer>();
tempList.add(5);
system.debug(tempList);
//above line gives USER_DEBUG|[4]|DEBUG|(5)
my_list_2.add(tempList);
system.debug(my_list_2);
//above line gives USER_DEBUG|[6]|DEBUG|((5))
hii
i wanted to know
how to separate list<List<String>>
like i have used this map
Map<Id,List<List<String>>> servMap = new Map<Id,List<List<String>>>();
//implemented MAP
for(Service__c serObj: serviceList){
Id parentAccId = serObj.Customer__r.Grand_Parent_Account__c;
String AccountId = String.valueOf(serObj.Customer__r.id);
String count= String.valueOf(serObj.Count_of_Pickup_Days__c);
List<String> childDetailsList = new List<String>{AccountId, count};
if(serObj.Status__c == 'Active'){
if(servMap.get(parentAccId)==null)
{
servMap.put(parentAccId,new list<List<String>>{childDetailsList});
}
else
{
servMap.get(parentAccId).add(childDetailsList);
}
}
}
now i have this result through map...........parentID----->(ChildID,PickupDays) in debug
now i want to get Pickup days values of all the child that are coming in debug like
0+1+2+1+3+2+1 = 10 total value
for(Id ParentAccountID:servMap.keySet()){
List<List<String>> ChildList= servMap.get(ParentAccountID);
System.debug('---ChildList---'+ChildList);
}
now the childList is coming with pickup days value in Debug and i want pickup days and SUM them
so tell me how to separate this List<List<String>>