 Hello, everyone. Welcome to this video series based on Java collections. Okay, in this video, we are going to see overview of collections in Java. I am Professor Dattadri Gangmal from Wolchen Institute of Technology, Solapur. So, let us begin with this video and try to learn collections in Java. What will be the learning outcome in this particular video? Okay, at the end of the session, students will be able to describe the advantages of collections. Okay, and second, differentiate various collection types. That's the main motive in this particular video. We are going to see what is the advantage of collections and how many types of collections we have overall in Java. Okay, we will have a rough estimate about it. Before starting with collections, I would like to elaborate and put my point on need of collections. Why there is need of collections? Here you can see there are various things that need to be taken note of. Okay, first is limitations while using array. We say collection is a replacement for arrays. In short, I'll come to it later. Okay, for now, understand that we are trying to have a better array type. So there are certain limitations in array. Okay, what limitations we have in array? First is we cannot store different class objects into a same array. Let's say I want to store integer, flow, double data types into a single array, it is not possible. Likewise, various objects like if there is an employee object, there is a student object. If I want to store an employee object and a student object which belongs to a different category, okay, different objects. And if I want to store them in a single data type that is single type of an array, it is not possible. Okay, another thing is adding or inserting an element in between an array. Okay, if it is from start of an array or end of an array is easier, we can say a of zero or a of size minus one, it will get deleted. But the thing is, if you want to delete an element in between, what you will do, you will you will write a code like saying that okay, until and unless I get a particular element and your your pointer will go from one point to another point like it's it will go sequentially. Serial it will go right. But the problem here is if say you have 10,000 records, okay, and if you want to delete and the element is present at 9000 plus location, okay, then your array or your array pointer is going to search from zero location to 9000 plus location. And it is going to take that much amount of time. So it basically deleting once you delete what happens once you delete that element will become that particular slot will become empty. Okay, that will become of no use. Means if if you delete a record at location 10, okay, nine and 11 cannot be connected 10 will always be there. Okay, I cannot move the 11th element over at 10th position. Even if I move it, it will take a lot of time. That's a disadvantage in arrays. Okay, whatever size you allocate, it will be fixed. If you want to eliminate any particular location in between, it is going to be tedious. Okay, you have to move all the elements after the element which you delete. If there are let's say 1000 elements after the element which you delete, you need to move all those 1000 elements shift one by one. Okay, so that that's a tedious thing in arrays. And one more thing is, okay, element from an array is easy to get retrieving an element from an array is easy. But if you want to process, then there are no methods available. Let's say, you want to find a particular element in arrays is easy. Okay, let's say you want to sort an array. Or if you want to switch one one one by one, one by one element in between arrays, or you want to find the longest element, largest element, smallest element, that is very difficult in collections. Okay, I'm sorry, it is very difficult in arrays. Okay, so to remove this hurdle, we have collections. This is how we declare usually arrays, okay, int array, here are equal to new int, many other ways are possible. So you'll you store the element at 0th location, first location, second location, and so on. This is usually how we do it in arrays. Okay, if you if I want to print, or if I want to store employee records, okay, and if I want to print it later, I usually I require a for loop to do this. If they let's say you have 100 employee records, and you want to create 100 elements into it, this is how we do it. So this disadvantages of array can be overcome or limitations of array can be overcome using collections. The first advantage of using collection is size can be increased dynamically. If let's say you have 10 elements, 10 size can be allocated. If you have 100 elements, 100 can be allocated in between you delete 50 elements. And again, you want to minimize your size, it can be done. But in arrays, you cannot do that. Once you declare the size, it is fixed. And also insertion any element in between and retrieval is at any particular location is easier in case of collections. And also one of the most important advantage of using collections is various different data types can be stored at using one object of collection. Let's say you want to store integer, double float everything in one at one place in one bucket that can be done using collections. We will see don't worry about it. We will see each and everything minutely. So in case of Java, okay, all your classes related to collections are present inside a package called a Java dot util. All your collections are present over here, collection classes. What are different collection classes? In collection classes, we have interfaces as well as classes associated in Java. Okay, what are those? These are the list asset, linked asset, list, stack, link list, array list, vector, q, ash map and ash table. Okay, I'll tell you specifically which is an interface and which is a class. So this is a table which shows these are the interfaces and these are the implementation classes. There are four interface in Java collections. Okay, set list q and map. In set, we have two classes asset and linked asset. In list, we have four classes, stack, link list, array list, vector. In q, again, we have link list. In map, we have ash map and ash tables. We will see all these collections in this video series. Don't worry about it. And it is very easy. Compared to arrays, I will say that collections are more easier. When many people say that collections are difficult to understand. But in this video series, you will see that collections are much easier to learn. It's a small question for you people. How many interfaces we have in Java collections? Yes, how many interfaces we have in Java collection? Just now we have seen it. Okay, if you are not able to answer it, you can recall this video, rewind this video and see it. The answer for this is four. We have four interfaces. Just now we have seen it, right? Set list q and map. How we are going to declare an array list and what are the steps involved in creating an array list. Let us see that. Now going one by one. Let us first see what array list exactly is. Array list is a type of collection. Okay, that implements the list interface. We have seen some interfaces types. Okay, so Array list falls under the category of list interface. Okay, Array list is one of the basic collection type and it is the most easiest collection type to learn. It uses a dynamic array to create the elements of different data types. Okay, so as I said in collections, you can store various data types into a single collection location. Okay, that is Array list. Now let us see how Array list is going to get created. So public static void mean your program Java program in this we have Array list ARR equal to new Array list. So here in this first line object is created. What is the object name over here? ARR. What is its type? Array list. Okay, what is there any data type associated with it? No, any data type is allowed over here. It is generic. Now, if you want to add elements into this array list, the method which is available in this Array list collection is add. To add, we will use ARR.add. ARR.add will add elements to this particular Array list. ARR.add 10, 12, and some element 23. Any number of elements you can add it. There is no fixed size. Okay, here you can see I have not given any size over here, specific size over here. So collections grows and decreases as per the need. That's the beauty of collections. Here to display all these elements, we are going to use a forage loop in Java. So how we are going to declare a forage loop in Java? It is simple for int i in ARR. Here all the elements are of type integer. Okay, so int i colon ARR is going to have a pointer which is going to run sequentially using a pointer named AI. Okay, system.out.println i. What i is going to do here? i is going to print all the elements in ARR. This for loop is going to run incrementally until all the elements are displayed from ARR. That is for each loop. Okay, I can even do it using for loop also. But just to make you learn more concepts, I am using here for each loop. Fine. So that's it about array list. And again, we have various display types like in we have iterator, we have list iterator, okay, we have enumerator. We are we are going to we will be seeing all this display methods very soon. Okay, fine. That's it from this particular video series. The first video we have learned about array list and why we are going to use collections, okay, different types of collections. These are some of the references. Thank you.