How to Find Length of an Array in Java


In this example, we will learn the method to find the length of an array in Java.

Source Code

package com.beginner.examples;

public class ArrayLength {
  public static void main(String[] args) {
    String[] strs = {"a", "b", "c", "d"};
    System.out.println(strs.length); // get the length of an array 
  }
}

Output:

4
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments