function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
List<Integer> allList = new List<Integer>{1,2,3,4,5,6,7,8}; Map<String, Integer> sumMap = new Map<String, Integer>(); sumMap.put('Ans',0); for(Integer i : allList) { Integer temp = sumMap.get('Ans'); if(i % 2 !=0) temp+=i; sumMap.put('Ans',temp); } System.debug('Answer is' + sumMap.get('Ans'));
Lets assume that you have the List of integer for which you have to calculate sum of odd Number