Java.util.IntSummaryStatistics class with Examples6 Jan 2025 | 3 min read The java.util package consists of the IntSummaryStatistics class. When performing operations on a stream of integers, it accepts a collection of Integer objects and can be effective. It keeps track of how many numbers it has processed, how much they have added up to, and other statistics. The class is compatible with Streams as well. It can be used to manipulate statistical data because it keeps track of the operating sum, average, etc., of the integers. Thus making it convenient. The Class Hierarchy of the IntSummaryStatistics class is: The Constructors that can be implemented are: 1. IntSummaryStatistics(): A default constructor sets the count and total to zero by default and sets max to Integer.MIN_VALUE and min to Integer.MAX_VALUE. Syntax: 2. IntSummaryStatistics(count, min, max, sum): Initializes all the distinct data members using the parameters that were given in during the process of calling method. Syntax: The Methods that are used are: 1. accept() - The given integer is added by this function to the statistical data. Syntax: 2. combine(): This function combines the current statistics data with the data from the given IntSummaryStatistics object. Syntax: 3. getCount(): The count of the numbers that have been handled is returned by this method. Syntax: 4. getSum(): The total of all the integers processed is the result of this method. Syntax: 5. getAverage(): The average of all the integers processed is the result of this method. Syntax: 6. getMin(): The minimum value of all the integers processed is the result of this method. Syntax: 7. getMax(): The maximum value of all the integers processed is the result of this method. Syntax: 8. toString(): The string representation of each element of statistical information present in the object is what this method returns. Syntax: Example:The program in Java demonstrates the way to collect statistics about a list of integers using the IntSummaryStatistics class. The first step is to initialize a list of integers and create an instance of IntSummaryStatistics. Each integer is added to the IntSummaryStatistics object as iteratively traversing the list using an iterator. Count, average, sum, maximum, and minimum values of the list members are among the statistical measurements printed by the program after the statistics object has been filled. Ultimately, all of these details are included in a single string that is the string representation of the summary statistics. Implementation: FileName: IntSummaryStatisticsExample.java Output:
The count of all the given values is: 10
The average of all the given values is: 49.5
The sum of all the given values is: 495
The maximum of all the given values is: 99
The minimum of all the given values is: 0
The string representation of the given values is:
IntSummaryStatistics{count=10, sum=495, min=0, average=49.500000, max=99}
|
Serialization and Deserialization of a Binary Tree in Java
Serialization is the process of converting a data structure (like a binary tree) into a format that can be stored or transmitted and then reconstructed later. Deserialization is the reverse process, where the serialized format is converted back into the original data structure. For a binary tree,...
15 min read
Java Program to Illustrate Use of Binary Literals
The enhanced support for numerical representations in Java 7 included the introduction of binary literals. A number that is represented in binary (0s and 1s) is called a binary literal. Binary literals can be used for integral types like byte, short, int, and long in Java....
5 min read
Different Packages in Java
to extensive library support. These libraries, organized as packages, provide a rich set of tools and functions that simplify development, increase code reuse, and encourage maintenance. In this comprehensive section, we will explore Java packages, their purpose, special features, and how they contribute to the overall...
8 min read
Java Logger
In Java, logging is an important feature that helps developers to trace out the errors. Java is the programming language that comes with the logging approach. It provides a Logging API that was introduced in Java 1.4 version. It provides the ability to capture the log...
8 min read
Bytecode Verifier in Java
When it comes to the world of programming languages, Java stands out as one of the most popular and versatile choices. One of the key features that sets Java apart is its portability, allowing developers to write code once and run it anywhere. This portability...
4 min read
How to Download Minecraft Java Edition
Minecraft is a sandbox video game developed by Mojang Studios. It is written in Java programming language. It is developed by Markus Persson. In May 2009, it was released for personal computers. The Minecraft Java edition is a cross-platform play between Windows, Linux, and macOS. It...
4 min read
Pernicious Number in Java
In this section, we will discuss what is pernicious number and also create Java programs to check if the given number is a pernicious number or not. The pernicious number program frequently asked in Java coding interviews and academics. Pernicious Number If the total number of 1's in...
4 min read
Dynamic Variable in Java
Java, a versatile and widely used programming language, provides a range of features to make programming efficient and flexible. One such feature is dynamic variables. Dynamic variables offer a powerful way to manage data and manipulate it during runtime. In this section, we will delve into...
3 min read
How to Break a Date and Time in Java
? Java programs frequently need to break down dates and times, particularly those that deal with scheduling, event management, and data analysis. The LocalDate, LocalTime, LocalDateTime, and DateTimeFormatter classes are just a few of Java's classes and methods for managing dates and times. To decompose a date and...
4 min read
DoubleBuffer arrayOffset() Method in Java With Examples
The offset of the buffer's first element within its underlying array can be obtained by calling the arrayOffset() method of the java.nio.DoubleBuffer class. In other words, buffer position p corresponds to array index p + array Offset() if this buffer is supported by an array. We...
3 min read
We request you to subscribe our newsletter for upcoming updates.

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