And the scolding lecture, we're going to use lottery numbers as an example.
So first, create a new class for this right.
Click new Java class, raise up it and now copy me method.
From her base to clear hit enter now create an array and square brackets.
Lottery numbers, the array name equals new keyword and square brackets, five and a semicolon to print
out the values in the array.
We are going to use a for each loop.
So for.
And.
Lottery number, Colin.
Lottery numbers, the source, then curly braces system that ordered print on lottery.
No, we didn't assign any values to the elements, so we expect that it will print out zeros to prove
it wrong.
How code?
Ron.
And it's correct now assign values to the elements, use the phrase name.
Lottery numbers, square brackets, index zero equals 17 semicolon now double this line four more times
changed indexes to one to three and four change the wall used to random numbers.
Just like this now running called again.
And now the array is filled up, our next step is to initialize a multidimensional array that stores
the weekly lottery numbers and instead of 54 weeks, we will use four weeks here.
Start with and double square brackets, the erased name, weekly lottery numbers equals curly braces.
And they semicolon their.
It's enter here.
Another curly brace, let's just make it simple, so one comma to comma, three comma, so and so on.
Now a comma after the first in curly braces, double this line a few times.
Change the world use.
Here to.
This one.
Just a few random numbers.
All right, and delete this last comma.
All right.
We are done with the initialization.
Now we're going to use simple for loop to go through the elements instead of messing with the definition
of a for loop.
There is a shortcut in intelligence.
If you type in four, I.
Here is a four high and hit enter, A.J. will define almost the whole for loop for you.
One thing is missing from here is the condition.
So I should be less than weekly lottery numbers, I thought.
Thanks, this for Loop is going to go through the rose, but we're going to need one for the columns
as well.
So we're going to need an inner for loop.
So for I hit enter and as you can see, instead of I introduce J because I has been reserved for the
other for loop now complete the condition here.
So weekly lottery numbers.
Square brackets.
I will show the road that we are currently and then land.
And that's it now print out the elements, so stand out that print alone, but instead of print line,
we're going to use the simple print function, which won't put every element in a new line.
So weekly lottery numbers, square brackets, the first one is going to be the role, which is I and
the second one is going to be J then plus and a space in double quotes for separation ad standard out
that print run after the in inner loop is ended.
So here, ok, the code seems fine.
Let's see the result.
Run the code.
The numbers are good, the format is correct.
That's it for now.
I hope it was useful and clear see in the next lecture.