Home > Java > javaTutorial > body text

Java Example - Get Array Length

黄舟
Release: 2017-02-18 09:59:44
Original
1476 people have browsed it

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);
   }}
Copy after login

The output result of running the above code is:

第一维数组长度: 2 
第二维数组长度: 5
Copy after login

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


source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!