Stream Even Square Average
EasyArrayStringjavaARRAY
# 🌊 Filter and Average using Java Streams
---
### Description
Given a list of integers, the task is to use Java Streams to process the list in the following sequence:
1. Filter all even numbers.
2. Square the remaining numbers.
3. Compute and return their average.
If the input array is empty or contains no even numbers, the result must be $0.0$. The final output should be formatted to 4 decimal places.
### Constraints
* $1 \le n \le 10^4$ (Size of array)
* $-10^4 \le arr[i] \le 10^4$
### Example
Input: $[1, 2, 3, 4, 5, 6]$
Output: $18.6667$
> Calculation: Even numbers $\rightarrow [2, 4, 6]$. Squares $\rightarrow [4, 16, 36]$. Average $= (4 + 16 + 36) / 3 \approx 18.6667$.
---
Examples
Example 1
Input: [1,2,3,4,5,6]
Output: 18.6667