how to set the length of an array in java code example
Example 1: .length array java
public class ArrayLengthJava {
public static void main(String[] args) {
String[] myArray = { "I", "Love", "Music" };
int arrayLength = myArray.length;
System.out.println("The length of the array is: " + arrayLength);
}
}
Example 2: find length of array java
Int[] array = {1,2,3};
int lengthOfArray = array.length;
System.out.println(String.valueOf(lengthOfArray));
Example 3: array declaration and initialization in java
int[] age = new int[5];
Example 4: set array length java
int[] num = new int[5];