Heidi this is so hard.
And welcome to the next video of this collection.
More do we now in this video we will check out varchar immutable set and they will.
So first of all let us start with the immutable set by using the set of keyword.
So here insert the intelligent ID largely modify my code.
So here I have simply written to a command line does say it contains the unique elements that has shared.
Also contains the unique elements but the sequence is not guaranteed in the output.
Right now let me explain you what is a set first.
So to define a set or in simple words the immutable set you can simply use that ARE.
My set equal to.
See set of keyword.
This contains the list of objects.
It simply expects that template let have a set of elements of integer type and insert this.
You have to simply define the values.
Let's say to the 4 3 1 0 and nurturing 9 9 and 9.
Again at last 8 this sort of Metford actually returns are immutable set that can only support the read
only operation and correctly.
I have only these set of elements that is the interior values.
So if you want to insert the string values then simply give their type as string and similarly simply
give their type as float.
If you want the Florida values but as of now I want the integer values for this more value right now
since this is immutable in nature so we can not modify the mice set later on.
That is you cannot insert more elements to it.
You can only perform the operations such as size stream contains and so on.
You can not add or remove the elements.
Now to print out the elements from this might say we need to use the for loop and up inline statement.
So for this.
The chords are very simple.
I will simply use element or any other variable you want.
In keyword my sig and now insert this let us print out the elements such as element and remove this
command and all of you are good to go.
Let us note in the chord so in the output console we can see some Viride output initially to 54 triva
and 0.
OK but after this we have only 9 here.
But while inserting the elements we had 3 9 instead of 1 right.
So how come these two are getting removed from the set now.
Initially I told you the search contained the unique elements.
So no matter how many elements of the values of 9 you insert it will automatically be removed from the
set because it is the property of the set that it can only contain the unique elements so that hidden
elements will be removed and no duplicate elements will be present.
Right so that is why see that certs only contain the unique elements.
Now suppose you want to modify your set so far that you need to use the mutable set.
Now again we need to change this set off to see new table set of integer values right.
So this will simply return on your table set which simply means that later on you can again modify your
search such as my search dog.
Remove any element such as I want to remove this 54.
So I will simply use 54 here and then run the code.
It will simply strike out the element off of default from our set and now the 54 is now gone.
So that is why we see that this new table set off does mutable set right and we can perform the read
and write Operation Boot no later on if you want to add some element so we can simply use my assert
and don't add and simply add legacy.
Hundred and run the code.
So in the output we have hundred as a last element.
Now this new set of actually returns the same object.
Right.
Now what about this.
Now what about this hash sake.
So far this let me show you one more example.
So instead of murid able to set off you can simply use hash of.
Now this will simply return the object of hash.
So right now if you are from a Java background then you must be knowing what this hash sect stands for.
It also contains the unique elements but the only difference between hash sake and said is that in the
hash sicht the sequence is not guaranteed in the output which means that.
Suppose I have two fifty four three and so on like this.
And right.
But for this set it will simply print or the values in the sequence.
But for the hash set the sequence does not matter.
And it does not guarantees that the elements will be rendered in the same sequence.
So as of now let us check out what happens in the output console.
So for this also let's just comment out remove and add operation.
Let us note in the chord and NIXEY of the elements are being entered in the sequence or not.
So here you can notice I have 0 1 2 3 54 8 and 9 the elements are not being entered in sequence because
the zero which is being printed as a first element it is actually present in the middle of all the hash.
So that and also this nine is actually printed at the end.
But it is present at the second and last element.
So the sequence in case of hash is not guaranteed but in case of set it is actually guaranteed.
So the only difference between the two they will off and hash set off is this only of the sequence.
So you can use either of these to ask but are you a requirement that they will accept and Buddh supports
read and write operation that is you can remove elements add element or replace any element and so on.
So finally we have reached the end of this more deal.
So in this more will we talked about the collections collections and collections and also it talked
about the immutable collection and mutable collection in all the cases of list map and set.
Now if you remember all these mentors such as list of map of and set off and all these methods that
I have mentioned here add a list of hash map off and so on.
You will face new difficulty for their data structure in Carter-Long.
So make sure you remember there are differences between the immutable and mutable collections and the
respective metrics of least map and stick.
So this is considered signing off and thanks for watching and have a good day.
Thank you.