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
mahi rafimahi rafi 

how to calculate sum of odd no.s using map for{1,2,3,4,5,6,7,8}

Hi Find the Code below,
Lets assume that you have the List of integer for which you have to calculate sum of odd Number
List<Integer> allList = new List<Integer>{1,2,3,4,5,6,7,8};
Map<String, Integer> sumMap = new Map<String, Integer>();
for(Integer i : allList)
	Integer temp = sumMap.get('Ans');
	if(i % 2 !=0)
System.debug('Answer is' + sumMap.get('Ans'));