In this post, we're gonna learn about arrays in Java.
Array is a data structure that used to store multiple values in one single variable instead of declaring separate variables for each value.
Data Type: It defines the element type of the array.[ ]: It defines the size of the array.arrayName: It is the Name of array
Each element in the array has an index that we can access the element by it.
For example when you want to return the first element in the array:-
System.out.println(cars.length); // Outputs 4
by using the for loop or for each and the length property of the array we can looping the array elements in Java.
In this post, we learned how to use arrays in Java.
Most popular tags