-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
8
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
Hello Team,
I am a java developer and do the job. Today I was reading LongStream and LongSummaryStatistics for OJP 11 certification. During the study, I see the discrepancy between average method of both classes.
LongStream.average() returns OptionalDouble() containing the average element of the stream, or an empty optional if the stream is empty which is expected result
while LongSummaryStatistics.getAverage() returns average double value of values or 0 if no element.
My question is that why LongSummaryStatistics.getAverage() returns 0 if no element there . It should also return OptionalDouble as LongStream.average().
Current logic creates the confusion why statistics class returning 0.0 in case of empty and like this we need to write to check two different logic. 0.0 can be valid value of average like we have two elements, 2 and -2 and average of both is 0.0.
System.out.println(" 0.0/2 = "+ (0.0/2));
Result :- 0.0/2 = 0.0
In this case, how we can say stream was empty or not.
Hope, You understand what I want to say here and team will look into this issue.
FREQUENCY : always
Hello Team,
I am a java developer and do the job. Today I was reading LongStream and LongSummaryStatistics for OJP 11 certification. During the study, I see the discrepancy between average method of both classes.
LongStream.average() returns OptionalDouble() containing the average element of the stream, or an empty optional if the stream is empty which is expected result
while LongSummaryStatistics.getAverage() returns average double value of values or 0 if no element.
My question is that why LongSummaryStatistics.getAverage() returns 0 if no element there . It should also return OptionalDouble as LongStream.average().
Current logic creates the confusion why statistics class returning 0.0 in case of empty and like this we need to write to check two different logic. 0.0 can be valid value of average like we have two elements, 2 and -2 and average of both is 0.0.
System.out.println(" 0.0/2 = "+ (0.0/2));
Result :- 0.0/2 = 0.0
In this case, how we can say stream was empty or not.
Hope, You understand what I want to say here and team will look into this issue.
FREQUENCY : always