Heidi rings at the heart once again welcome to the next More deal of discourse of Cartland programming.
Now in this morning we talk about collections in Cartland.
So first of all what other topics are covered in this mondial.
So firstly I will show you Vawter collections by simply using the examples of addy's in Scotland.
Now the areas in Scotland are actually mutable in nature.
Bert has fixed size.
Now if you are from Java background then you must be doing Vardis areas transform.
It is simply the collection of elements that is integer strings and so on.
Such as add a string of endangered Arey offload and so on.
So we will check out is addy and vord business.
New table stands for.
And why do we see that Addie has fixed size now proceeding forward we will check out the actual collections
in Cartland such as immutable collections and also the mutable collections.
Right now if you notice there are two sections here.
The immutable collection and mutable collection you can note is immutable collection are actually READ
ONLY that is once you define the collection that is the Adye or list or map or set.
We can only read data from that collection but the mutable collection supports both read and write operation.
That is once we define our collection such as a list or map or sets we can read and write both.
That is we can modify the list or the collection in future as well.
So similarly the area is actually mutable in nature that is we can modify our era in future as well.
So in this video just for the introduction I will show you vort is an addy and how can we define the
addy in Carter-Long.
So if you understand the concept of adding in this video then from the next value onwards you won't
face any difficulty to understand the list.
Map and sets both immutable and mutable.
So let's check out the area inside the intelligence ID.
So here insert the intelligent ID just to do find the ID.
The syntax is like this.
So that or they'll let us find the name as my addy.
As of now equal to let's see Adie now expects a complete darkness.
That type of added that you want to create.
So as of now I want to create the integer empty the added that will hold only the bigger value.
So as we go to defining the empty object that is my ID.
You have to define the size of the Attie that is the number of elements that this adic and contain are
the integer values that it can contain.
So as of now I will simply give five.
Now proceeding forward give it a space and here expects the second parameter as a lambda value.
Now you already know warder's the lambda in case of Gorlin stands for.
So inside the lambda are doctors in between the parentheses.
There does the curly braces you have to define the initial value of all the elements of the Attie.
So here let us initialize it to zero.
Right.
So we have simply defined Adye of integers.
That is my Adye that can only contain 5 elements and the initial value of all the elements is zero.
Now if you look at the representation of the at a typical Airey you will find this right.
So here I have five elements.
So all the five elements is actually represented with the help of a particular index.
So this is an index such as 0 1 2 3 and 4.
Now notice we have five elements but the index starts from 0 and ends in 4.
That is five minus one is four right.
If I put here 6 then the index will move ahead such as 5 and a value will again be zero.
Now these are the elements the initial value that we are defining it here.
So all the elements initially has a value of zero.
Now if I put here let's see minus 1.
So instead of 0 we will have minus 1 minus 1 and so on.
All the values will change from 0 to minus 1.
So as of now let us keep it 0 only right.
That or just to show you now proceeding forward as the areas are actually immutable in nature but has
fixed size.
So once we have defined the addy should only contain the five elements.
So it will only have five elements right.
We can not make it 6 in future.
Right.
And it is New Day will in nature that is Rick and Morty Feydeau values present inside the Attie such
as if you want to change the element add the index of zero to let's see 32.
So now then the code will be executed this zeroth index that is that this index will now contain 32
instead of zero.
So here Zero will not become 32.
Right now if I change let's see my every index of let's see 3 I want to change that toward index element
2.
Let's see 54.
So here instead of 0.
I will get 54 as the integer value right.
So this shows that the areas are actually mutable in nature that is once defined.
You can change the values right now if you want to print the values so for that you can simply use print
line Lerche see my addy and simply use the index note to find the index.
You'll simply need to use the square brackets square brackets open and close.
Now insert this.
You will simply use.
Let's say I'm on the plane they're told LMA.
Or the fourth element.
So far that you have to use the index of three.
So let us note in the chord
so the output console will we get 50 for as the output.
Now if you want to print all the elements present inside the Adye that is right from 30 to 0.
So far that we need to use those for each loop such as.
Define element in operator followed by my addy not the concept of for a loop.
We already saw in the previous Mordy was right.
So let us define.
Lindsay was pretty plain statement.
Or insert of these simply use element.
So this will simply paint all the elements present inside the mighty.
And here we get all the output 32 zeros rule 54 and 0.
Now make a note here that the element present at 1 and 2 and 4.
We have not had initialized that is.
It is by default 0 that we have defined here.
So if you want you can also change modify the value by providing the index legacy index.
At 1 equal to 10 or living like this.
Let us note in the chord.
And here we get Lemon here.
Right now if I suppose use the index of let's say my addy for the index Let's see nine or eight equal
or do let's say crania 3.
So since we know that the size of the area is only 5 so from where we are getting the aid index.
So if we're in the court right now it was simply through an error that add a index out of bounds exception.
Right.
As expected an index out of bounds exception because our added does not contain the eighth or ninth
element.
Right.
So there is no possibility of having the index of it.
So that is why it has simply thrown the error.
And that is why we see that we cannot add more elements as mentioned here in future.
So that is why please make a note please remove discord and now we are simply printing element inside
the Adye and simply printing that element.
Suppose if you want to print all the elements with the help of the index so far that you've already
got to do is simply use the form to provide the index variable in my addy or the range zero dot dot.
Let's see for.
So index will vary from 0 1 to 3 and 4 narked will be more specific.
So here we have 0 1 2 3 and 4 like this right now to be more specific instead of 40 you can simply use
my every dot size minus one.
That is my radar will simply done 5 right so minus 1 will not be done for.
So this will all become finally fought like this.
So it is a more generalized form and then simply print the my ID of the index.
So the index will simply vary from 0 1 to 3 and 4 and it will simply print out all the elements present
inside the area.
So here let us use red line or the new line character and note in the chord.
So in the output console we get 32 0 and then again Tardieu to zero.
So in both of these works are working perfectly fine.
So this is the way to print all the elements inside the collection.
So in the upcoming videos they will use these two loops again to print out all the elements present
inside the collection.
Now at the end of this video.
I would again like to highlight this point and add this area has a fixed size.
So this is actually the problem for us.
Suppose you want to add elements in the future.
But you cannot do it.
So for that we will check out the aerialist in Codlin in the next video.
So please make sure you check out my next video.
This is considered signing off.
And thanks for watching and have a good day.