1/**
2* An Example to get the Array Length is Java
3*/
4public class ArrayLengthJava {
5public static void main(String[] args) {
6String[] myArray = { "I", "Love", "Music" };
7int arrayLength = myArray.length; //array length attribute
8System.out.println("The length of the array is: " + arrayLength);
9}
10}
11
1Int[] array = {1,2,3};
2int lengthOfArray = array.length; /** Finding the length of the array and storing it */
3System.out.println(String.valueOf(lengthOfArray)); /** Should print out 3, String.value Of() is optional as printLn does this automatically. */
1let coolCars = ['ford', 'chevy'];
2//to find length, use the array's built in method
3let length = coolCars.length;
4//length == 2.
1class Main {
2 public static void main(String[] args) {
3 // Creating an array called x.
4 String[] x = new String[]{"This", "Should", "return", "4"};
5 // "x.length" finds the length of the array "x".
6 System.out.println(x.length);
7 // returns 4
8 }
9}