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
- CopyOnWriteArraySet size() method in Java
- Vector size() Method in Java
- CopyOnWriteArrayList size() method in Java
- LinkedHashSet size() method in Java
- ArrayDeque size() Method in Java
- HashSet size() Method in Java
- EnumMap size() Method in Java
- LinkedList 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.