int array length java code example

Example 1: .length array java

/**
* An Example to get the Array Length is Java
*/
public class ArrayLengthJava {
public static void main(String[] args) {
String[] myArray = { "I", "Love", "Music" };
int arrayLength = myArray.length; //array length attribute
System.out.println("The length of the array is: " + arrayLength);
}
}

Example 2: length of array in java

arr.length;

Example 3: set array length java

int[] num = new int[5];

Example 4: java get size of array

arrayname.length

Tags:

Cpp Example