 Hi guys, so in this video we're going to be taking a look at how we can traverse arrays in order to access each item sequentially within the array. So we already know that if we have an array called data, we can access the first item of the array at data zero, the second item of the array at data one, and so on and so on, all the way down to the last item which we can access at the index data dot length minus one. So as we access each item, the only thing that changes is the counter. So since the counter or index is the only thing that's changing, what we can do is we can put it into a for loop where the first value is zero and the last value is one less than data dot length. And for each item we access, we can perform some action. So for example, we might want to display each item at index I. Now it's important to be aware of why this is less than and not less than or equal to. And the reason is that the final item in the array is accessed at the index data dot length minus one, which is one less than data dot length, obviously. Therefore, if we make this less than or equal to, we'll get an index out of bounds exception when the loop tries to access the item at index data dot length, which doesn't exist. So now let's take a look at an example of array traversal in Eclipse. All right. So in this example, we're going to be creating this random fill array method here. And what this method does is it takes an integer array data, and it sets each item in data to a random value between zero and nine inclusive. All right, so how can we go ahead and do this? So in order to set each item in the array, we're going to need to traverse the array in order to access each item. So first, we're going to go ahead and create a for loop just like we did in the previous example. And it's going to look the exact same. I plus plus. So now for each index I, we're going to be setting data I. And we can randomize the value like so. So data I equals the integer part of math dot random times 10. So here math dot random is a value between zero and one, including zero but excluding one. And multiplying that by 10 gives us a number between zero and 10, including zero but excluding 10. And then we cost it to an integer value to give us a value between zero and nine inclusive. So that's how that part there is working. So now up in the main method here, I've just created an array of length four. Run our method with my new array as the actual parameter down here. And I've then created a loop that just prints out each item in the array once the method's been run. So let's just go ahead and run this and see what happens. And you can see that the array now contains my array data here. Now contains four values, four, nine, one, two. Run it again, nine, eight, six, nine. So you can see it's filling each time we run the program. This method here is filling our array with random values between zero and nine. All right, so that was just a quick video on array traversal using for loops. So I hope you found it helpful and thank you for watching. Bye.