Java.util.DoubleSummaryStatistics class with ExamplesThe contents of the java.util package pertains to the DoubleSummaryStatistics class. It is essential when working with a stream of large precision real numbers and requires a collection of Double objects. It keeps track of the total number of values it has processed, as well as a number of additional statistics. Streams can also be utilized with this type. In order to manipulate statistical data, it is helpful because it keeps track of the doubles' running sum, average, and other metrics. The Class Hierarchy is given by: The constructor that is used is: DoubleSummaryStatistics(): A constructor, by default, sets max to Double and initializes the count and total to 0.NEGATIVE_INFINITY with a minimum of Double.POSITIVE_INFINITY. Syntax: The methods that are used are: 1. accept(): This function incorporates the double that was given in into the statistical data. Syntax: 2. combine(): The DoubleSummaryStatistics object that has been passed along and the current statistics data are combined by this function. Syntax: 3. getCount(): The count of the number of doubles handled is returned by this method. Syntax: 4. getSum(): The total of all the doubles that were processed is the result that this method returns. Syntax: 5. getAverage(): The average of all the doubles processed is the result of this method. Syntax: 6. getMin(): The lowest double among all the doubles processed is the result of this method. Syntax: 7. getMax(): The maximum double of all the doubles processed is the result of this method. Syntax: 8. toString(): The string representation of each element of statistical information present in the object is the value that this method returns. Syntax: Example:This example demonstrates how to use the built-in utilities in Java to compute and display basic statistics for a set of numerical data. The DoubleSummaryStatisticsExample program shows how to extract statistical information from a list of double values using the DoubleSummaryStatistics class from the java.util package. Implementation: FileName: DoubleSummaryStatisticsExample.java Output: The count of all the values is 10 The average of all the values is 11008.03457 The sum of all the values is 110080.3457 The maximum of all the values is 46654.9 The minimum of all the values is 0.001 The string representation is given by DoubleSummaryStatistics{count=10, sum=110080.345700, min=0.001000, average=11008.034570, max=46654.900000} |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India