There is no size() method available with the array. But there is a length field available in the array that can be used to find the length or size of the array.
array.length: length is a final variable applicable for arrays. With the help of the length variable, we can obtain the size of the array.
int size = arr.length; // length can be used // for int, double, String // to know the length of the arrays.
Below is the illustration of how to get the length of array in Java using length variable:
The size of the array is 4
The size of the array is 3
Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.
- How to determine length or size of a String in Java?
- Determine the Upper Bound of a Two Dimensional Array in Java
- Java Program to Determine Hostname from IP Address
- Java Program to Determine if a given Matrix is a Sparse Matrix
- How to determine if an array contains a specific value in PHP?
- Difference between length of Array and size of ArrayList in Java
- How to determine the direction of a jQuery scroll event?
- How to determine active route in AngularJS ?
- How to find the length or size of an ArrayList in Java
- length vs length() in Java
- HashMap Class Methods in Java with Examples | Set 1 (put(), get(), isEmpty() and size())
- Dictionary size() Method in Java with Examples
- TreeSet size() Method in Java
- LinkedBlockingDeque size() method in Java
- EnumMap size() Method in Java
- Size of file on the Internet using Java
- ArrayBlockingQueue size() Method in Java
- LinkedList size() Method in Java
- HashSet size() Method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.