1 00:00:00,900 --> 00:00:06,420 Heidi rings at the heart once again welcome to the next More deal of discourse of Cartland programming. 2 00:00:06,540 --> 00:00:10,150 Now in this morning we talk about collections in Cartland. 3 00:00:10,590 --> 00:00:14,820 So first of all what other topics are covered in this mondial. 4 00:00:14,820 --> 00:00:21,000 So firstly I will show you Vawter collections by simply using the examples of addy's in Scotland. 5 00:00:21,270 --> 00:00:25,190 Now the areas in Scotland are actually mutable in nature. 6 00:00:25,230 --> 00:00:27,290 Bert has fixed size. 7 00:00:27,330 --> 00:00:32,500 Now if you are from Java background then you must be doing Vardis areas transform. 8 00:00:32,610 --> 00:00:38,120 It is simply the collection of elements that is integer strings and so on. 9 00:00:38,250 --> 00:00:43,570 Such as add a string of endangered Arey offload and so on. 10 00:00:43,620 --> 00:00:46,660 So we will check out is addy and vord business. 11 00:00:46,680 --> 00:00:48,100 New table stands for. 12 00:00:48,300 --> 00:00:55,110 And why do we see that Addie has fixed size now proceeding forward we will check out the actual collections 13 00:00:55,110 --> 00:01:01,670 in Cartland such as immutable collections and also the mutable collections. 14 00:01:01,710 --> 00:01:04,730 Right now if you notice there are two sections here. 15 00:01:04,770 --> 00:01:11,700 The immutable collection and mutable collection you can note is immutable collection are actually READ 16 00:01:11,760 --> 00:01:18,590 ONLY that is once you define the collection that is the Adye or list or map or set. 17 00:01:18,690 --> 00:01:28,010 We can only read data from that collection but the mutable collection supports both read and write operation. 18 00:01:28,110 --> 00:01:35,380 That is once we define our collection such as a list or map or sets we can read and write both. 19 00:01:35,440 --> 00:01:40,520 That is we can modify the list or the collection in future as well. 20 00:01:40,840 --> 00:01:48,850 So similarly the area is actually mutable in nature that is we can modify our era in future as well. 21 00:01:49,050 --> 00:01:54,840 So in this video just for the introduction I will show you vort is an addy and how can we define the 22 00:01:54,840 --> 00:01:56,330 addy in Carter-Long. 23 00:01:56,370 --> 00:02:01,890 So if you understand the concept of adding in this video then from the next value onwards you won't 24 00:02:01,890 --> 00:02:04,610 face any difficulty to understand the list. 25 00:02:04,660 --> 00:02:08,220 Map and sets both immutable and mutable. 26 00:02:08,220 --> 00:02:12,660 So let's check out the area inside the intelligence ID. 27 00:02:12,700 --> 00:02:16,510 So here insert the intelligent ID just to do find the ID. 28 00:02:16,540 --> 00:02:18,440 The syntax is like this. 29 00:02:18,550 --> 00:02:23,250 So that or they'll let us find the name as my addy. 30 00:02:23,290 --> 00:02:30,450 As of now equal to let's see Adie now expects a complete darkness. 31 00:02:30,490 --> 00:02:33,020 That type of added that you want to create. 32 00:02:33,340 --> 00:02:40,130 So as of now I want to create the integer empty the added that will hold only the bigger value. 33 00:02:40,330 --> 00:02:44,620 So as we go to defining the empty object that is my ID. 34 00:02:44,740 --> 00:02:50,920 You have to define the size of the Attie that is the number of elements that this adic and contain are 35 00:02:50,920 --> 00:02:53,600 the integer values that it can contain. 36 00:02:53,650 --> 00:02:56,410 So as of now I will simply give five. 37 00:02:56,610 --> 00:03:04,120 Now proceeding forward give it a space and here expects the second parameter as a lambda value. 38 00:03:04,120 --> 00:03:08,890 Now you already know warder's the lambda in case of Gorlin stands for. 39 00:03:08,980 --> 00:03:12,250 So inside the lambda are doctors in between the parentheses. 40 00:03:12,430 --> 00:03:19,470 There does the curly braces you have to define the initial value of all the elements of the Attie. 41 00:03:19,480 --> 00:03:22,370 So here let us initialize it to zero. 42 00:03:23,120 --> 00:03:23,830 Right. 43 00:03:24,000 --> 00:03:27,010 So we have simply defined Adye of integers. 44 00:03:27,030 --> 00:03:34,830 That is my Adye that can only contain 5 elements and the initial value of all the elements is zero. 45 00:03:35,810 --> 00:03:41,930 Now if you look at the representation of the at a typical Airey you will find this right. 46 00:03:41,990 --> 00:03:44,240 So here I have five elements. 47 00:03:44,270 --> 00:03:49,600 So all the five elements is actually represented with the help of a particular index. 48 00:03:49,760 --> 00:03:54,740 So this is an index such as 0 1 2 3 and 4. 49 00:03:54,740 --> 00:04:00,050 Now notice we have five elements but the index starts from 0 and ends in 4. 50 00:04:00,080 --> 00:04:03,010 That is five minus one is four right. 51 00:04:03,020 --> 00:04:10,640 If I put here 6 then the index will move ahead such as 5 and a value will again be zero. 52 00:04:10,640 --> 00:04:14,990 Now these are the elements the initial value that we are defining it here. 53 00:04:15,170 --> 00:04:18,560 So all the elements initially has a value of zero. 54 00:04:18,560 --> 00:04:21,170 Now if I put here let's see minus 1. 55 00:04:21,170 --> 00:04:26,020 So instead of 0 we will have minus 1 minus 1 and so on. 56 00:04:26,020 --> 00:04:29,120 All the values will change from 0 to minus 1. 57 00:04:29,180 --> 00:04:32,560 So as of now let us keep it 0 only right. 58 00:04:33,620 --> 00:04:40,580 That or just to show you now proceeding forward as the areas are actually immutable in nature but has 59 00:04:40,670 --> 00:04:41,840 fixed size. 60 00:04:41,870 --> 00:04:46,460 So once we have defined the addy should only contain the five elements. 61 00:04:46,490 --> 00:04:49,700 So it will only have five elements right. 62 00:04:49,720 --> 00:04:52,090 We can not make it 6 in future. 63 00:04:52,400 --> 00:04:52,990 Right. 64 00:04:53,000 --> 00:04:59,060 And it is New Day will in nature that is Rick and Morty Feydeau values present inside the Attie such 65 00:04:59,060 --> 00:05:07,300 as if you want to change the element add the index of zero to let's see 32. 66 00:05:07,540 --> 00:05:14,800 So now then the code will be executed this zeroth index that is that this index will now contain 32 67 00:05:14,830 --> 00:05:15,900 instead of zero. 68 00:05:15,940 --> 00:05:18,200 So here Zero will not become 32. 69 00:05:18,260 --> 00:05:26,500 Right now if I change let's see my every index of let's see 3 I want to change that toward index element 70 00:05:26,710 --> 00:05:27,310 2. 71 00:05:27,580 --> 00:05:30,290 Let's see 54. 72 00:05:30,370 --> 00:05:31,780 So here instead of 0. 73 00:05:31,810 --> 00:05:35,160 I will get 54 as the integer value right. 74 00:05:36,120 --> 00:05:40,710 So this shows that the areas are actually mutable in nature that is once defined. 75 00:05:40,710 --> 00:05:47,840 You can change the values right now if you want to print the values so for that you can simply use print 76 00:05:47,840 --> 00:05:54,200 line Lerche see my addy and simply use the index note to find the index. 77 00:05:54,210 --> 00:05:58,640 You'll simply need to use the square brackets square brackets open and close. 78 00:05:58,650 --> 00:05:59,820 Now insert this. 79 00:05:59,820 --> 00:06:00,720 You will simply use. 80 00:06:00,750 --> 00:06:02,900 Let's say I'm on the plane they're told LMA. 81 00:06:03,120 --> 00:06:04,300 Or the fourth element. 82 00:06:04,320 --> 00:06:07,420 So far that you have to use the index of three. 83 00:06:07,500 --> 00:06:08,640 So let us note in the chord 84 00:06:11,690 --> 00:06:15,020 so the output console will we get 50 for as the output. 85 00:06:15,020 --> 00:06:21,840 Now if you want to print all the elements present inside the Adye that is right from 30 to 0. 86 00:06:21,860 --> 00:06:27,080 So far that we need to use those for each loop such as. 87 00:06:27,520 --> 00:06:33,610 Define element in operator followed by my addy not the concept of for a loop. 88 00:06:33,620 --> 00:06:36,570 We already saw in the previous Mordy was right. 89 00:06:36,650 --> 00:06:38,340 So let us define. 90 00:06:38,360 --> 00:06:40,460 Lindsay was pretty plain statement. 91 00:06:40,660 --> 00:06:43,220 Or insert of these simply use element. 92 00:06:43,430 --> 00:06:48,010 So this will simply paint all the elements present inside the mighty. 93 00:06:48,180 --> 00:06:52,240 And here we get all the output 32 zeros rule 54 and 0. 94 00:06:52,230 --> 00:06:56,240 Now make a note here that the element present at 1 and 2 and 4. 95 00:06:56,250 --> 00:06:58,540 We have not had initialized that is. 96 00:06:58,540 --> 00:07:01,410 It is by default 0 that we have defined here. 97 00:07:01,470 --> 00:07:07,390 So if you want you can also change modify the value by providing the index legacy index. 98 00:07:07,400 --> 00:07:11,080 At 1 equal to 10 or living like this. 99 00:07:11,190 --> 00:07:13,020 Let us note in the chord. 100 00:07:13,240 --> 00:07:15,060 And here we get Lemon here. 101 00:07:15,190 --> 00:07:23,820 Right now if I suppose use the index of let's say my addy for the index Let's see nine or eight equal 102 00:07:23,820 --> 00:07:25,690 or do let's say crania 3. 103 00:07:25,690 --> 00:07:32,470 So since we know that the size of the area is only 5 so from where we are getting the aid index. 104 00:07:32,470 --> 00:07:39,180 So if we're in the court right now it was simply through an error that add a index out of bounds exception. 105 00:07:39,220 --> 00:07:39,620 Right. 106 00:07:39,640 --> 00:07:47,140 As expected an index out of bounds exception because our added does not contain the eighth or ninth 107 00:07:47,230 --> 00:07:47,810 element. 108 00:07:47,830 --> 00:07:48,430 Right. 109 00:07:48,670 --> 00:07:52,330 So there is no possibility of having the index of it. 110 00:07:52,330 --> 00:07:54,480 So that is why it has simply thrown the error. 111 00:07:54,640 --> 00:08:00,360 And that is why we see that we cannot add more elements as mentioned here in future. 112 00:08:00,370 --> 00:08:07,810 So that is why please make a note please remove discord and now we are simply printing element inside 113 00:08:07,810 --> 00:08:10,710 the Adye and simply printing that element. 114 00:08:10,720 --> 00:08:16,930 Suppose if you want to print all the elements with the help of the index so far that you've already 115 00:08:16,930 --> 00:08:27,080 got to do is simply use the form to provide the index variable in my addy or the range zero dot dot. 116 00:08:27,160 --> 00:08:28,870 Let's see for. 117 00:08:29,140 --> 00:08:35,850 So index will vary from 0 1 to 3 and 4 narked will be more specific. 118 00:08:35,860 --> 00:08:42,310 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 119 00:08:42,730 --> 00:08:47,160 my every dot size minus one. 120 00:08:47,230 --> 00:08:54,500 That is my radar will simply done 5 right so minus 1 will not be done for. 121 00:08:54,520 --> 00:08:58,640 So this will all become finally fought like this. 122 00:08:59,020 --> 00:09:07,290 So it is a more generalized form and then simply print the my ID of the index. 123 00:09:07,430 --> 00:09:14,060 So the index will simply vary from 0 1 to 3 and 4 and it will simply print out all the elements present 124 00:09:14,080 --> 00:09:15,310 inside the area. 125 00:09:15,530 --> 00:09:23,610 So here let us use red line or the new line character and note in the chord. 126 00:09:23,640 --> 00:09:30,130 So in the output console we get 32 0 and then again Tardieu to zero. 127 00:09:30,250 --> 00:09:33,180 So in both of these works are working perfectly fine. 128 00:09:33,190 --> 00:09:37,670 So this is the way to print all the elements inside the collection. 129 00:09:37,780 --> 00:09:43,570 So in the upcoming videos they will use these two loops again to print out all the elements present 130 00:09:43,570 --> 00:09:45,270 inside the collection. 131 00:09:45,280 --> 00:09:46,880 Now at the end of this video. 132 00:09:46,900 --> 00:09:51,750 I would again like to highlight this point and add this area has a fixed size. 133 00:09:51,940 --> 00:09:54,470 So this is actually the problem for us. 134 00:09:54,460 --> 00:09:56,670 Suppose you want to add elements in the future. 135 00:09:56,740 --> 00:09:57,960 But you cannot do it. 136 00:09:58,090 --> 00:10:02,340 So for that we will check out the aerialist in Codlin in the next video. 137 00:10:02,530 --> 00:10:04,850 So please make sure you check out my next video. 138 00:10:04,850 --> 00:10:06,450 This is considered signing off. 139 00:10:06,640 --> 00:10:08,550 And thanks for watching and have a good day.