WEBVTT

00:00.200 --> 00:00.710
Hi everyone.

00:00.710 --> 00:02.030
Welcome back to this tutorial.

00:02.030 --> 00:07.730
In this tutorial we will code and explore the summing end and averaging end collector.

00:08.870 --> 00:13.520
The summing in collector is going to return the sum as a result.

00:14.350 --> 00:18.720
The averaging ENT collector is going to return the average as a result.

00:18.730 --> 00:19.540
Like summing.

00:19.540 --> 00:27.880
And this collector has the support for summing long summing double averaging long and averaging double.

00:27.910 --> 00:33.290
But in this tutorial we are going to focus only on the summing ent and averaging ent.

00:33.310 --> 00:34.720
Let's go ahead and code this one.

00:37.090 --> 00:38.710
To have the example here.

00:40.060 --> 00:43.330
I close all these previous examples?

00:44.400 --> 00:49.470
In here what I'm going to do, I'm going to create a class called Dreams.

00:50.820 --> 00:52.620
Some average example.

00:54.250 --> 00:58.060
Let's make this class executable by adding public static void main method.

00:59.080 --> 01:00.220
Kostas console.

01:01.880 --> 01:03.650
Let me put this in presentation mode.

01:04.370 --> 01:07.400
The first example is we are going to explore the sum.

01:08.710 --> 01:11.080
Public static int.

01:14.430 --> 01:20.730
Okay, now we are going to use a student database class and get all the students.

01:21.780 --> 01:27.480
The use case that we are going to code is that if you take a look at this student object, it has a

01:27.480 --> 01:28.940
property called notebooks.

01:28.950 --> 01:35.910
So our use case is to perform summation of all the notebooks this whole student collection has.

01:36.360 --> 01:37.620
That's a use case use case.

01:37.620 --> 01:38.580
We are going to code.

01:39.120 --> 01:43.170
So after the student, after we got all the students, we are going to call the stream method.

01:43.170 --> 01:47.970
In the stream method we are going to perform the collect operation in here.

01:47.970 --> 01:50.730
We are going to call summing int.

01:53.160 --> 01:55.230
That's a character we are going to make use of.

01:55.890 --> 02:02.490
Use of it in this scenario and what we are going to pass, we are going to pass within Colon.

02:02.490 --> 02:02.970
Colon.

02:02.970 --> 02:04.650
Let's import the student first.

02:08.190 --> 02:10.890
Some reason it is not giving me the recommendation.

02:11.040 --> 02:13.440
Let's put both the colons here.

02:13.440 --> 02:15.630
I believe it is going to give you the recommendation now.

02:15.660 --> 02:16.200
There you go.

02:16.200 --> 02:22.590
We have successfully imported the student and in here we are going to use the get notebooks, which

02:22.590 --> 02:26.370
is going to return the notebooks of each and every student.

02:26.370 --> 02:31.950
And the collect is going to accumulate all the values by performing the summation of each value that

02:31.950 --> 02:34.830
is being passed from the stream and return the result.

02:35.150 --> 02:37.280
So I'm going to add the return statement here.

02:37.290 --> 02:44.190
This return statement is going to return the whole summation of all the notebooks from all the students

02:44.550 --> 02:45.150
I'm going to print.

02:45.150 --> 02:50.400
The value here is going to be total number of notebooks.

02:51.700 --> 02:54.940
And then the method that it is going to call is sum.

02:55.090 --> 02:57.990
Let's run this example and check the result.

03:00.150 --> 03:00.640
There you go.

03:00.660 --> 03:03.120
It printed the result as 71.

03:03.300 --> 03:08.010
So this is all about the summing int let's explore the averaging int.

03:10.620 --> 03:13.170
So I'm going to name this one as average.

03:14.250 --> 03:19.860
And then instead of summing it, we are going to use averaging and there you go, averaging it.

03:19.860 --> 03:24.630
Like I mentioned in the presentation, it has the long version and double version too, but we are going

03:24.630 --> 03:26.520
to focus only on the averaging end.

03:27.690 --> 03:31.920
And if we take a look at the averaging end, it returns a type as double.

03:32.490 --> 03:35.430
So we are going to return the type as double.

03:40.260 --> 03:41.460
But s going to be.

03:42.520 --> 03:44.650
Average number of notebooks.

03:46.830 --> 03:51.840
Is a text, which I'm going to add, and then we are going to call the average method.

03:51.960 --> 03:56.760
So the average method performs a averaging and let's go ahead and run this one.

03:58.490 --> 04:03.920
So the average number of notebooks that each and every student has is 11.83.

04:04.340 --> 04:08.780
So this is all about summing and and averaging it collector.

04:10.650 --> 04:10.950
But this.

04:10.950 --> 04:12.400
We came to the end of this tutorial.

04:12.420 --> 04:13.530
Thank you for watching.
