1 00:00:02,100 --> 00:00:05,940 And the scolding lecture, we're going to use lottery numbers as an example. 2 00:00:06,280 --> 00:00:09,500 So first, create a new class for this right. 3 00:00:09,500 --> 00:00:19,830 Click new Java class, raise up it and now copy me method. 4 00:00:21,410 --> 00:00:31,610 From her base to clear hit enter now create an array and square brackets. 5 00:00:33,700 --> 00:00:48,090 Lottery numbers, the array name equals new keyword and square brackets, five and a semicolon to print 6 00:00:48,090 --> 00:00:49,570 out the values in the array. 7 00:00:49,590 --> 00:00:52,160 We are going to use a for each loop. 8 00:00:52,830 --> 00:00:54,030 So for. 9 00:00:57,140 --> 00:00:57,740 And. 10 00:00:59,530 --> 00:01:05,290 Lottery number, Colin. 11 00:01:07,000 --> 00:01:15,560 Lottery numbers, the source, then curly braces system that ordered print on lottery. 12 00:01:15,580 --> 00:01:23,530 No, we didn't assign any values to the elements, so we expect that it will print out zeros to prove 13 00:01:23,530 --> 00:01:23,910 it wrong. 14 00:01:23,950 --> 00:01:24,610 How code? 15 00:01:25,750 --> 00:01:26,230 Ron. 16 00:01:28,590 --> 00:01:35,250 And it's correct now assign values to the elements, use the phrase name. 17 00:01:37,380 --> 00:01:52,290 Lottery numbers, square brackets, index zero equals 17 semicolon now double this line four more times 18 00:01:53,940 --> 00:02:05,580 changed indexes to one to three and four change the wall used to random numbers. 19 00:02:11,090 --> 00:02:13,640 Just like this now running called again. 20 00:02:15,510 --> 00:02:22,350 And now the array is filled up, our next step is to initialize a multidimensional array that stores 21 00:02:22,350 --> 00:02:28,860 the weekly lottery numbers and instead of 54 weeks, we will use four weeks here. 22 00:02:30,150 --> 00:02:48,180 Start with and double square brackets, the erased name, weekly lottery numbers equals curly braces. 23 00:02:49,740 --> 00:02:52,590 And they semicolon their. 24 00:02:53,660 --> 00:02:54,950 It's enter here. 25 00:02:56,550 --> 00:03:07,770 Another curly brace, let's just make it simple, so one comma to comma, three comma, so and so on. 26 00:03:09,570 --> 00:03:17,790 Now a comma after the first in curly braces, double this line a few times. 27 00:03:20,180 --> 00:03:21,800 Change the world use. 28 00:03:27,030 --> 00:03:28,200 Here to. 29 00:03:35,460 --> 00:03:36,150 This one. 30 00:03:40,770 --> 00:03:42,630 Just a few random numbers. 31 00:03:43,770 --> 00:03:46,470 All right, and delete this last comma. 32 00:03:46,830 --> 00:03:47,340 All right. 33 00:03:47,350 --> 00:03:49,300 We are done with the initialization. 34 00:03:49,740 --> 00:03:56,100 Now we're going to use simple for loop to go through the elements instead of messing with the definition 35 00:03:56,100 --> 00:03:57,380 of a for loop. 36 00:03:57,570 --> 00:03:59,640 There is a shortcut in intelligence. 37 00:04:00,030 --> 00:04:02,460 If you type in four, I. 38 00:04:03,780 --> 00:04:12,550 Here is a four high and hit enter, A.J. will define almost the whole for loop for you. 39 00:04:12,870 --> 00:04:15,510 One thing is missing from here is the condition. 40 00:04:15,780 --> 00:04:21,540 So I should be less than weekly lottery numbers, I thought. 41 00:04:22,340 --> 00:04:30,230 Thanks, this for Loop is going to go through the rose, but we're going to need one for the columns 42 00:04:30,230 --> 00:04:30,780 as well. 43 00:04:31,010 --> 00:04:33,290 So we're going to need an inner for loop. 44 00:04:33,830 --> 00:04:44,330 So for I hit enter and as you can see, instead of I introduce J because I has been reserved for the 45 00:04:44,330 --> 00:04:49,900 other for loop now complete the condition here. 46 00:04:50,510 --> 00:04:54,260 So weekly lottery numbers. 47 00:04:55,390 --> 00:04:56,800 Square brackets. 48 00:04:57,770 --> 00:05:04,490 I will show the road that we are currently and then land. 49 00:05:06,320 --> 00:05:15,620 And that's it now print out the elements, so stand out that print alone, but instead of print line, 50 00:05:15,620 --> 00:05:23,000 we're going to use the simple print function, which won't put every element in a new line. 51 00:05:23,630 --> 00:05:33,560 So weekly lottery numbers, square brackets, the first one is going to be the role, which is I and 52 00:05:33,560 --> 00:05:45,020 the second one is going to be J then plus and a space in double quotes for separation ad standard out 53 00:05:45,020 --> 00:05:47,860 that print run after the in inner loop is ended. 54 00:05:48,740 --> 00:05:53,230 So here, ok, the code seems fine. 55 00:05:53,240 --> 00:05:54,470 Let's see the result. 56 00:05:54,650 --> 00:05:55,520 Run the code. 57 00:05:58,750 --> 00:06:01,240 The numbers are good, the format is correct. 58 00:06:01,870 --> 00:06:02,900 That's it for now. 59 00:06:02,950 --> 00:06:06,580 I hope it was useful and clear see in the next lecture.