 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can limit a generic class so that it can work for some specific data types. This demonstration is in Java. Before starting, you can subscribe my YouTube channel by clicking on the link which is available at the bottom right corner of this video. You can download my app Techimace that is available on Google Play. You can connect with me by following these details which are available in front of you. Now coming on to the topic. First of all, I am going to explain stats class. Then I will be explaining second class, which is Jan demo. So stats class is having this notation T extends number. So number is a predefined class. I am extending this class for T, which will which is working as a data type here. So right now this T is not specified. It will be specified when object of this stats class will be created. Then an array of T data type is created with nums. Then constructor of class is created, which is receiving an argument in O and this O is assigned into nums. Then a method is defined, which is average. Its return type is double. It is calculating sum of array nums and values of nums is accessed through a method double value. This double value method is defined inside number class. So this double value method access the values which are available inside array, but this array must belongs to the data type which are numeric data types like int, float, double, etc. After calculation of sum, return statement is returning an average which is division of sum by nums.length. So sum is containing sum of all the elements and nums.length is containing number of elements. So this average will be returned by this average method. So with the help of this statement, first statement we are limiting this class that it this class will work for numeric data types like int, float, etc. Now with the help of this class, I will be creating object of stats class. So first an array of integer class is created, which is having five elements. Then object of stats class iob is created and it is having integer as a type parameter. And i nums array is passed here. So this i nums array will be received by this O and O is assigning this array into nums and then this method will be processed. So this method is called here iob.average. So this method will work. The resultant value will be assigned to V and the output will be displayed with the help of this system.out.println. Similar to i nums array, d nums array is created for double and then stats object dob is created. So the type parameter is double. So for iob, this t will be replaced in integer and for this dob, the t will be replaced in double. And rest of the statements are similar like average method is called and the result is assigned into w and w is printed here. You can see some more statements which are commented. The statement is saying this won't compile because string is not a subclass of number. So I have already explained that we have limited our generate class to numbers. If you are using any data type which doesn't belongs to number class, then your code will not compile. So that's why these statements are coming right now. So I am executing this code by making these statements as comment so that we can receive correct output. So you can see the average 3.0 and 3.33. 3.0 is for iob and 3.3 is for dob. So it is printing correct results. Now I am making I am uncommenting or I have uncommented these statements. You can see an error message is available here and it is saying the type string is not a valid substitute for the bounded parameter t extends number of the type stats t. So friends you can see that by applying bounded types on a particular generate class, you can limit the type which you want to apply on that class. So here I have applied number class so that I can use int float and double data types. If I want to use string or Boolean data types, then compiler will show an error message. So this is all about how you can limit or bound a particular class for some particular data types. I hope you have understood the concept well. If you want to watch more programming related videos, you can subscribe my YouTube channel. Thank you for watching this video.