Given a list of integers, return the sum of all even numbers in the list. Return 0 for null or empty lists. Return 0 if the list contains no even numbers.
Examples:
Input: numbers = [1, 2, 3, 4, 5, 6]
Output: 12
Explanation: 2 + 4 + 6 = 12
Input: numbers = [1, 3, 5]
Output: 0
Explanation: No even numbers in the list
Input: numbers = [2, 4, 6]
Output: 12
Input: numbers = []
Output: 0
Input: numbers = null
Output: 0
Apex Code Editor
Welcome to Lightning Challenge!
How It Works
- • Write your solution in the code editor
- • Connect your Salesforce org to test
- • Submit to check if your solution passes
- • Use hints if you get stuck
Contest Alert
🏆 #CodeEveryDay August 2026
Contest runs August 1 - 31. Complete challenges to climb the leaderboard!
Only the 31 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.