0% found this document useful (0 votes)
2 views5 pages

Java 8 Average Calculation Tutorial

The document discusses a Java interview question about calculating the average of numbers in a list after squaring them and filtering out any numbers greater than 100. It provides the input as a list of integers and the question. It then outlines the solution using Java 8 methods like map(), filter(), mapToInt(), and average().
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

Java 8 Average Calculation Tutorial

The document discusses a Java interview question about calculating the average of numbers in a list after squaring them and filtering out any numbers greater than 100. It provides the input as a list of integers and the question. It then outlines the solution using Java 8 methods like map(), filter(), mapToInt(), and average().
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Interview Series

Shiva Prasad
Gurram

Hi, I'm Hi, I'm


Shiva Q-4 Jaanu
Do you have
any Java 8 Yes, I do
experience?
Good! Let's see how
you can use Java 8
to answer the below
question. Sure
Input
List<Integer> list = [Link](1,7,8,9,5,2,36,4,78,222,24,9);

Question
Get the average of a list of numbers after squaring them and
filtering out any that are bigger than 100.

Solution
We need to square each number ( We can use map())
Filter those who are greater than 100 (we can use filter())
Find average of those (we can use mapToInt() and
average() together)
For more articles like this, follow me.

Join

@dailydsawithspg

Shiva Prasad Gurram

You might also like