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