‫Welcome back.
‫In this video, we are going to have a look at a race and several ways of creating and using a race.
‫So let's get started.
‫We are in a main method again and in here I will create an integer array.
‫So let's just create one and I'm going to call that one.
‫Great.
‫And this is going to be a new int five array.
‫Now that means that we have an array which is of type integer and it has five values or at least has
‫a space for five values.
‫So we define straight away how many different values we want to store in that array in order to add
‫those values to the array.
‫We have multiple ways.
‫So one would be we assign at a specific index, we assign a specific value.
‫So let's say one is a great student and he has 20 points or we has a grade of 20.
‫Then the second grade is going to be, let's say 15 and so forth.
‫So now I can go ahead and I can add the grade to my array and I always have to be specific with the
‫index.
‫So from 0 to 4, those are the five values that I want to add to the array of grades.
‫And of course, I could change the values up a little bit.
‫So it's not going to be all great students, but some have worse marks as well.
‫All right.
‫So that's generally how you can create an array, so how you can initialize it, how you can add the
‫values, and now in order to access it.
‫So let's just access it.
‫And I'm going to use see W which is a code snippet for console, right line double tap and I get console
‫right down and here I simply say grades at index zero.
‫And in here we use the curly brackets again at the position zero and that will be great.
‫So as you see, it always starts off at zero.
‫So computers, they start counting at zero.
‫That's the point here.
‫So that alone will not be enough.
‫We want to see the console as well.
‫So console the read key
‫and now let's see again.
‫Great at index zero is 20.
‫All right.
‫And that's exactly what we have here.
‫So this is how you can access it.
‫And if you want like to change it afterwards, you can do so.
‫So let's say somebody presses the key and I want to change the value and I want to give it out again.
‫So here I just say, great, or actually let's get the value the user enters and let's make an integer
‫out of it.
‫So we just say string input is equal to console dot red line and now we need to make sure that the input
‫is transferred to an integer because grades can only contain ints.
‫So we have to make sure that grades at the position is going to be an actual integer.
‫So how do we do that?
‫Can you still remember?
‫So this one will be the insecure version.
‫So try parse would be the safer version.
‫But I'm just going to use Parse now because I know that I'm just going to enter a whole numbers.
‫So in here I will parse the input.
‫Now.
‫Let's check it out.
‫Rates at index zero is 20.
‫Now let's say we changed it to ten, creates an index, zero is ten now.
‫So this is how you can simply change the value any time, right?
‫So here you assign in this line, I assign a value.
‫Assign value to array great at index zero.
‫And here we declare and initialize.
‫All right.
‫There are, however, different ways to create arrays or to initialize arrays.
‫So these are the ones that we've seen.
‫Now let's check out others.
‫So let's say we have another array and we call it grades of math students A and that will be in curly
‫brackets, the values that I want to assign.
‫So let's say I have 20, 13, 12, eight, eight.
‫So these are the values that my students of Class A have.
‫So that's another way of initializing.
‫And then there is a third way and that's again the data type square brackets, and then you enter the
‫name again, great of math students.
‫B And that will be a new int and here I declare double where I enter the values again.
‫So 1520 317
‫actually 20 will be the highest value.
‫So let's say these are the other values that I have.
‫So as you can see this array here, so grades of math students B has a length of six.
‫So there are six values and students A is only five values.
‫So in order to get the length of an array, you can use the array name.
‫So grades of students, a dot length.
‫As you can see, there is a property called length and gets a total number of elements in all the dimensions
‫of the array.
‫So let's print that out onto the console.
‫So I'm just going to use CW tab, tab and in here I'm going to just say.
‫Length of rates or actually I copied that.
‫No, I did not copy it.
‫And that will be the value of great length or great of my students at length.
‫And again, I'm going to use Red Key here.
‫Now let's run it.
‫And here I just need to enter something again.
‫I'm going to use that.
‫And then the length of grades of math Student A is five.
‫So we have five values in there and that's exactly what we got in here.
‫So in order to get the length and you just use the property length, that will come in handy quite often.
‫So it's really important to understand that concept.
‫So in the next video we are going to have a look at for each loops I told you about for each loops as
‫we were talking about loops in general.
‫But I haven't covered it yet because we needed to understand the concept of race first and that's why
‫we're going to start off with for each in the next video.
‫So see there.