Languages
[Edit]
EN

Java - how to get size of array

4 points
Created by:
JustMike
26120

In java every array has property .length not a method .length() or .size().

Examples:

int[] intArray = new int[3];
int length = intArray.length; // 3

int[] intArray = {1, 2, 3};
int length = intArray.length; // 3

String[] stringArray = new String[3];
int length = stringArray.length; // 3

String[] stringArray = {"A", "B", "C"};
int length = stringArray.length; // 3

 

Native Advertising
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

❤️💻 🙂

Join