‫Welcome back.
‫In this tutorial, we're going to learn about arrays In Java.
‫Arrays are used to store multiple values of the same data type in a single variable.
‫They are containers that can hold a fixed number of elements, and each element in the array can be
‫accessed using an index.
‫Let's start learning the basic syntax of creating an array data type.
‫This is the note I want from you to understand it well and write it down too.
‫Angled brackets refers to the array.
‫Here we start with the array name equal to new data type, and here we specify the array size and of
‫course we close and end the line with a semicolon.
‫This is the basic syntax of the array.
‫How to create an array in Java.
‫Let's take an example of an array of type integers.
‫So the data type would be int array.
‫You can see it's the data type is an int, the angled brackets here and here we specify the array name,
‫I'll name it as numbers array equal new.
‫This is the new keyword.
‫And that creates for us the array.
‫And here we specify again the data type and we specify the size of the array.
‫Let me start with an array creating an array with five boxes.
‫So we created an array of type integers that can hold five elements.
‫Now, how to start?
‫Filling this array, how to store values in the array in order to access and store that data.
‫Store variables in the array.
‫We start with the name of the array numbers array, and here we specify the index.
‫The index represents the position of an element within the array.
‫It's an integer value that starts from zero and goes up to the size of the array minus one.
‫Each element in the array is associated with a unique index to store values in the array.
‫At the first index, we start with zero, not one.
‫It's zero.
‫The first index I am filling the first box in this array at index zero.
‫I am filling it with number for example.
‫Ten.
‫The second box in the array is accessed by one and I'm filling it with 20.
‫And so on.
‫I am filling this array with the numbers.
‫Numbers.
‫Array Index.
‫Three.
‫Equal to 40 and numbers array at index four equal to 50.
‫Now.
‫As I told you.
‫The value of the index starts from zero and go through the size of the array minus one.
‫So the size of the array five minus one is four.
‫So the maximum index we can reach is number four.
‫So we start with zero and we end with four, which is five minus one.
‫Remember that the index starts from zero.
‫So the first element is at index zero and the second element is an index one and so on.
‫Now let's try to access the elements in the array and print them.
‫Let's start with System.out.print line and I'll start typing with the element at index zero, index
‫zero and I'll give the value and call the array at index zero.
‫This is how we access the array.
‫It's similar to how we fill it.
‫Here I'm assigning the number, the value ten to the first index.
‫Here I am getting and calling the array and getting the value of the element stored in the index zero.
‫Here I am calling it.
‫Okay, let's run the program and here we go.
‫The element at index zero is equal to ten, and this is the value of the first element in this array.
‫Congratulations, guys.
‫We learned how to create the arrays in Java, the syntax of creating the arrays.
‫We learned how to store values in the array.
‫We'll learn about index in the array.
‫And we learned how to access and print elements of an array.