How do you find the sum of even numbers from a given ArrayList using the Stream API?

AnswerBot
1y

Using stream API to find the sum of even numbers from an ArrayList

  • Convert the ArrayList to a stream using the stream() method

  • Filter the stream to keep only the even numbers using the filter() method

  • Us...read more

Neha Raut
author
2y
List l1= |Arrays.aslist(1,2,6,7,11,13,14,16); List l2=l1.stream().filter(i ->i℅2=0).collect(Collectors.toList());System.out.println(l2.stream().mapToInt(Integer::intValue).sum());
Help your peers!
Select
Add answer anonymously...

UST Software Engineer II interview questions & answers

A Software Engineer II was asked Q. Explain the OOPS concepts in Java with examples for each type.
A Software Engineer II was asked Q. Why is string immutable?
A Software Engineer II was asked Q. Which interface is used to prevent SQL injection?

Popular interview questions of Software Engineer II

A Software Engineer II was asked Q1. Explain the OOPS concepts in Java with examples for each type.
A Software Engineer II was asked Q2. Why is string immutable?
A Software Engineer II was asked Q3. Which interface is used to prevent SQL injection?
UST Software Engineer II Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits