High this is getting at the heart once again welcome to the next video of this collection.
More to now.
In the previous two videos we talked about the Adye and list in girdling.
So in this video we will discuss about the maps in Garling.
So inside the map the Village Code Vawter immutable map and murid table map.
So first of all let's take the immutable map that supports only read only operation using that method
of map of.
So here inside the intelligent Id let me clean up my code.
So what is actually a map now the map is actually their data structure.
So this data structure contains the elements in the form of key value pair.
So each value is specified is connected to a specific key that you will check out shortly.
So what do we mean by this is to define a map.
We need to use the VAT or value keyword.
Let's see my map equals to map of.
Now this map of the regions the immutable map.
Now this map of keyword actually returns the immutable map that is it cannot be mortified later once
defined and it has also the fixed size and it can support the read only operation that is you can only
read the content of the map but cannot modify in future aspart your requirement.
So to define a map you can simply use map of followed by their template.
Now their template contains the key value before the key can be laid.
And in either case.
And the value can be a string.
Right now this key can also be a good order.
This can also be flawed.
But anarchies I'm keeping it in.
Right.
And this value can also be and and any combination can be applicable here.
As you would wish and flowed into string into God and Boullion and so on.
But right now just use string right now since we have defined the end and string as a key value period.
That is the key will be in.
And the value will be string.
So inside the constructor.
So while initializing all the values we have to define the key value pair in a similar fashion that
is let us define the key as to who going to.
Let's see Yugi separated by a comma second element Nerk see 43 going to alert them and move on.
And then the third element does define the key value appeared as let's say seven going to be.
So here I have simply defined the key value.
Here is the key as a first element and as a first element I have the value of Yugi and here the key
is 2:56 value as Menuhin keys 7 and value as fee now make a note here that inside the map since they
are present in a sequence.
But the key need not to be in sequence that is.
This too can be fought as well.
Right.
And therefore it is not necessary that it has to be a greater number.
It can be any number it can be one as well.
So there is no sequence of the key.
You're going to define any interior value.
So the form will only map to Yugi and 43 will only map to 1.
And now since this my map is actually immutable in nature.
So you cannot say put any other elements inside this that is once defined you can not mortify in future
you can only print or the values using the print and in the statement or the for loop.
Right.
So it's for this let's just print out the elements inside the immutable map by using the key.
So here I would simply define the key and then my map door keys.
So my map darkeys will simply return all the keys.
Is fluid 43 and 7 and stewarded inside the key variable.
One by one.
So here I will simply use large see my map of key.
So my map of Kiev is simply the return the value associated with that key that is your game and Mohon
and speed.
And in the output console you will get all the outputs the output.
So here we go to Yugi maneuver and Vajpeyi And now instead of my map of the key.
You can also right let's see my map Dorte get the value are this key.
So instead of my map key you can also use my map dord get the value Akki right.
So both ways it will work.
So here let me mortify my brain.
And in the statement.
So here element present at this key and here I am simply appending are the key and also the map dot
gate key.
So here I will use my map and are get are in sort of this.
You can also use my map are the index of key.
Right.
So let us note in the chord.
So here we get element agcy that is Axford we have Yugi at 43 I have Manoharan at 7.
I have Vice B.
Now in future suppose you want to mortify large c I am going to modify my map so far that you can do
it because it is immutable in nature.
So the Cartland provides the mutable map that is immutable collections.
So inside of them you will map.
You can simply use hash map hash map of mewled table map of.
So let us try these things inserted there in Delage ID.
So any sort of map or if you can simply use the hash map.
So this hash map again if you are from Java background then you must be familiar with this hash map.
It contains a value as a key value pair.
Now redefine a hash map there just remove all these called from here.
And on that site I would simply use my map Dorte and then simply pass the first pyramided aski.
Let's see.
Food coma UGI and similarly I will add my movement and watch be.
So here I have simply added two more elements and here this hash map is actually mutable in nature.
There it is we can perform the read and write operation Buddh and it has no fixed size.
There it is.
In future we can add more and more elements.
As for our vish.
And now to print out all the elements the code will be same as we have defined here.
So as of now let us run the call and we get the same output in the output console.
Right.
Now suppose in future you want to replace this man than by let's see Moody.
So later on what we'll do inside your code you will simply use my map dord.
Let's see say replace method.
Now simply define the key as 43 and then the new value to be inserted.
Legacy Mordy.
So whatever is present.
So whatever value is associated with 43 key will be replaced by Moody.
So this movement will be removed and it will be replaced by Moody.
So let us note in the chord.
So here we get Axford we have Yugi seven vice B and at 43 instead of Menuhin I have more D.
And now instead of using the replace you can also use the method.
Now insert the apartment.
If you pass 43 and then the new value.
Then again it will work like replacement.
So at 43 it will simply insert moody and maneuver and will be forgotten.
So let's see what happens.
So in the output again we have an index of agcy of 43.
We have the someone movement is on now at the end of this video.
I would like to show you a few more things now instead of hash mathy You can also use a few more keywords
such as table map of.
And also you can use hash map off.
Now all these three are actually representing a hash map.
The only difference is that this new table map of actually returns of the hash map.
Now since this is a big net of course.
So as of now I do not want to talk more about this link.
Hash map but just remember more or less all these three are seeing all these three are actually returning
a hash map.
So in this video we talked about the map off and also hash map hash map off and mutable map of.
And also we learned the difference between the mutable map and immutable map.
So in the next video we will check out Vawter immutable set and they will have said that has their own
functions such as say golf and your table is set off and so on.
Let's take out in the next video.
Thank you.