Implement the avgOnSet method that accepts a stream of Integer elements, accumulates them to a Set, and returns the average value of numbers from the set.
Remember to use the collect operation to solve the problem.
Implement the avgOnSet method that accepts a stream of Integer elements, accumulates them to a Set, and returns the average value of numbers from the set.
Remember to use the collect operation to solve the problem.
Sample Input 1:
1 3 1 3 1Sample Output 1:
2.0Sample Input 2:
1 2 3 4 2Sample Output 2:
2.5Create a free account to access the full topic