 Hello everyone. Welcome back. Now let us start with linked asset in collections. I am Professor Dutta Drakandamal from Walchin Institute of Technology, Solapur. What students will be able to learn? Students will be able to learn and describe linked asset along with various methods available in linked asset. Second, students will be able to do a program using linked asset in collections. If I come to the description part of linked asset, linked asset works on the principle of Ashtable. It is based on the interface set. Contains unique elements again. As we have seen in Ashtable, same again in linked asset also it will contain unique elements. It will not allow the duplicate elements into Ashtable. It provides operations like set and permit and it allows null operations, null elements. It is non synchronized and it is again going to maintain an insertion order because it is a link list. It is based on the linked list properties. So, even if Ashtable will come into picture, that can be connected using this link list. Therefore, it can maintain an insertion order. The way you insert the elements can be stored in that particular manner only. That can be achieved only because of linked list. These are popular ways that can be created for linked asset, asset collection, linked asset and linked asset. These are the four ways that can be created. So, here you can see that this is for default and second one is you are passing some collection of other element and third way is you are giving some capacity to it and fourth way you are giving the capacity as well as the field ratio. How much should be the field ratio? So, these values are provided. So, all these constructors are available in linked asset. Let us quickly start with a program coming to Eclipse. Let us create one more program. Let us try to close this, the previous one, new class linked hash demo. You can name anything. I can create an object using linked asset. I will give the take the elements as string or I will take an integer value just for change integer list 1 equal to new linked asset of type integer. So, list 1.add you will be adding let us say any number of elements. Let us say I am adding 10 list 1.add 20 list 1.add 30. So, I am adding three elements into it. You can use both ways. Now, like if I use a for each loop for int i in list 1 says out if I put i over here it will be iterating incrementally 10-20-30. Remove this for loop. Use a while loop while we will be using an iterator for this. Iterator of type integer it equal to list 1.iterator. Iterator will start pointing over here. Then we will have this method it.asNext. If it is having an element it is going to print it. So, sysout it.next is going to print if a element is present at the next location. Let us see yes 10-20-30. It is working fine. Now, let us try to do it on duplicate elements list 1.add 20. Let us try to add 20 once again. Let us see whether 20 is accepted or not. If I run it I will keep intact everything as it is. Only I am adding one more line list 1.add. If I try to print the output is 20 is coming only once which is already inserted. So, every time this particular collection types asset and linked asset is going to check whether that element is already present. If that element is already present it is not going to take the duplicate element into the collections. That is an important property. So, now when you are aware with array list, linked list, asset and linked asset you can see that array list allows duplicate, asset does not allow duplicate. So, based on application need a collection should be chosen. It should be picked based on the application. Let us say you want to store database for all other cards of the country. If you want to store the prepared database of all other cards available in the country then you should go for asset or linked asset because it will not allow duplicate elements and other card is unique. If your primary key is based on other card then you should use asset or linked asset because it will not allow duplicate elements. Whereas if you want to store just random names of students in a class there can be more than one Ankit in a class. There can be many students who are having the same name. In that case you will use array list. So, this collection type is going to change as per your application requirement. Sometimes you say that okay if you have more insertion operations go for array list. If you have more searching operations go for asset because in asset time required to search is minimum. Again we have seen that in array list if you have more deletion operations if you have more deletion operation go for linked list because we have seen if there is if you delete in element in between array list is going to take more time because it is going to shift all the elements after that. So, based on the requirement of an application you should smartly choose a collection type. Likewise we have more collection types such as tag queue. When you want to insert your elements in last in first out manner you should go for stack. If you want to insert an element on first in first out basis you should go for queue. Likewise smartly and a collection type should be chosen. Mostly if you see all my videos you can see that the methods used are almost the same but internally the complexity is different and the features are different some are allowing duplicate some are not allowing duplicate some are taking more time some are taking less time some are taking more time for searching some are taking more time for deletion. So likewise if you you have to take a judgment okay if I if this application is there let's say office records or employer records are there what will be there most of salary credits will be more employer deletion will happen sometimes not frequently but if you are taking a customer requirement customers database will be deleted regularly daily basis they will be deleted so deletion operations are more in that case. So likewise data set or collection type should be chosen. Okay now here in this case again if I want to copy one list to another list list two and if I take here 50 60 70 50 60 70 okay instead of list two I will take here it should be list two list two list two and if I want to copy for list one to list two it will be list two dot add all list one all the elements of list one will be copied to list two and here the iterator will change from list one to list two iterator dot as next everything will be intact as it is if I try to run it the output is 50 60 70 10 20 30 it is in the order of insertion so first 50 60 70 is added even if you change here if I put here 75 60 and 70 okay I'll take 75 over here 75 60 and 70 and try to run it the output will be 75 60 70 so it is based on the insertion order purely again if you want to remove an element it will be list two dot remove a particular element let's say you want to remove 60 and try to run it once again 60 will be removed from your list so it it collections has made this operations computation operations very easy they are on ease okay in array in if you if you recall array concepts in array doing such operations will take a lot of time right so coming back how many ways you can initiate a linked asset the answer is four ways okay these are some methods in linked asset the methods we have already seen while doing the program okay add a clear content splitterator and size okay these all methods can be used as per the requirement even as I said you can just do here a dot and you'll get all the list list two dot list two is off linked asset and these all methods are available here so the list will come fine as per the requirement you can choose the method and again when you do your list two dot and choose any method you can see its description as well here in eclipse it will give you for what purpose we are using this method okay so these are some of the references