1 00:00:00,180 --> 00:00:03,870 Before we start, did you try solving the workbook yourself? 2 00:00:03,900 --> 00:00:09,660 If not, please click the link in the resources folder and follow the instructions for this workbook. 3 00:00:10,020 --> 00:00:11,880 Welcome to Workbook 6.2. 4 00:00:11,880 --> 00:00:15,120 Instructions for this workbook are all learning the part. 5 00:00:15,240 --> 00:00:16,590 So let's begin. 6 00:00:16,950 --> 00:00:20,640 Task one Once again, create a new array of five students. 7 00:00:20,640 --> 00:00:25,410 So we're going to create an array that can store string elements called seeds. 8 00:00:25,500 --> 00:00:30,570 And the elements it will store are the ones from learn the Part. 9 00:00:31,780 --> 00:00:32,369 Okay. 10 00:00:32,500 --> 00:00:33,310 Looking good. 11 00:00:34,890 --> 00:00:39,690 And now, instead of creating five print statements for each element, we're going to have a four loop 12 00:00:39,690 --> 00:00:44,430 that's going to be tasked to create a four loop that runs through the length of the array and prints 13 00:00:44,430 --> 00:00:46,250 a message for each element. 14 00:00:46,260 --> 00:00:47,700 So we'll say four. 15 00:00:49,490 --> 00:00:53,990 INT I is going to start at index zero of the array. 16 00:00:54,020 --> 00:00:59,720 The for loop will keep running so long as the index I is smaller than the length of the array and every 17 00:00:59,720 --> 00:01:02,480 time the loop runs we increase ie by one. 18 00:01:03,670 --> 00:01:04,360 The counter. 19 00:01:04,360 --> 00:01:08,020 I will start at zero until it eventually reaches four. 20 00:01:10,020 --> 00:01:15,420 So when the loop is running, we can use AI to index every single element in the array. 21 00:01:30,010 --> 00:01:30,640 All right. 22 00:01:30,640 --> 00:01:34,870 The best way to understand what's going on is to visualize the runtime. 23 00:01:35,050 --> 00:01:39,670 So I will just put one breakpoint over here and let's begin. 24 00:01:45,130 --> 00:01:51,250 So because there are five elements, the length of this array is five. 25 00:01:52,630 --> 00:01:55,180 The for loop start at I equals zero. 26 00:01:55,210 --> 00:01:57,850 The element at index zero is Malfoy. 27 00:02:02,070 --> 00:02:06,930 When the for loop runs a second time, we're indexing the element at I equals one. 28 00:02:06,930 --> 00:02:08,160 So that's crab. 29 00:02:10,330 --> 00:02:12,820 Now we're at I equals two goil. 30 00:02:15,180 --> 00:02:17,160 I equals three pansy. 31 00:02:19,140 --> 00:02:21,090 I equals four, Dean. 32 00:02:22,480 --> 00:02:26,620 And now I a plus plus is going to increase our counter to five. 33 00:02:26,620 --> 00:02:28,840 The length of the array is five. 34 00:02:28,840 --> 00:02:30,670 Five is not smaller than five. 35 00:02:30,670 --> 00:02:33,670 So the for loop ends press continue. 36 00:02:33,670 --> 00:02:38,200 And we are done comparing this to what we have inside of learn the part. 37 00:02:38,930 --> 00:02:40,610 Everything looks perfect.