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
- How to determine length or size of a String in Java?
- Difference between length of Array and size of ArrayList in Java
- How to find the length or size of an ArrayList in Java
- How to determine if an array contains a specific value in PHP?
- length vs length() in Java
- Maximum number of Unique integers in Sub-Array of given size
- Set size() method in Java with Example
- WeakHashMap size() method in Java
- LinkedBlockingQueue size() method in Java
- LinkedHashSet size() method in Java
- AbstractSet size() method in Java with Example
- PriorityQueue size() Method in Java
- AbstractSequentialList size() method in Java with Example
- ArrayDeque size() Method in Java
- IdentityHashMap 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 firstname.lastname@example.org. 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.