In the previous chapter, we already learn about the array declaration, access, and change of the array element. Now we will learn about array length
Array length defines how many elements are in the array. Java gives us a built-in length property to find the length in an array. Through this, we can easily find out the length of an array.
Example:
Write the array name and then write the length followed by a dot ( . ).
String[] favourite_languages = {"Java", "Kotlin", "C++", "Python", "JavaScript", "Php"};
System.out.println("The array favourite_languages length is = " + favourite_languages.length); // access the array length.
Output:
The array favourite_languages length is = 6
Now the question is how to access all of the elements stored in an array. We can do this by using loops. In the next chapter, we will see how to access all the elements through a loop.