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
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}