Home  >  Article  >  Java  >  Java Example - Get Array Length

Java Example - Get Array Length

黄舟
黄舟Original
2017-02-18 09:59:441479browse

In this article, we will introduce how to use the length property of the array to get the length of the array.

In the following example, we define a two-dimensional array and obtain the length of the array:

/*
 author by w3cschool.cc
 文件名:Main.java 
 */public class Main {
   public static void main(String args[]) {
      String[][] data = new String[2][5];
      System.out.println("第一维数组长度: " + data.length);
      System.out.println("第二维数组长度: " + data[0].length);
   }}

The output result of running the above code is:

第一维数组长度: 2 
第二维数组长度: 5

The above is the Java example-getting the array The length of the content, please pay attention to the PHP Chinese website (www.php.cn) for more related content!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn