package java03;
/*
*如何获取数组长度 :
*   格式:
*           数组名称.length
*
*   这会得到一个int数字,代表数组的长度
*
*   数组一旦创建,程序运行期间,长度不可改变
*
* */

public class Demo04ArrayLength {
    public static void main(String[] args) {
        int[] arrayA = new int[3];
        int[] arrayB = {1,2,3,4,5,96,48,14,20,77,5,66,44,122,36,47,222,95,46,485,123};
        int len = arrayB.length;
        System.out.println("arrayB数组的长度是: "+ len);//21
        System.out.println("=================");

        int[] arrayC = new int[3];
        System.out.println(arrayC.length);//3
        arrayC = new int[5];
        System.out.println(arrayC.length);//5
    }
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-14
  • 2021-07-24
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
  • 2022-02-05
猜你喜欢
  • 2022-12-23
  • 2021-06-03
  • 2022-02-17
  • 2021-12-28
  • 2021-11-05
  • 2022-12-23
相关资源
相似解决方案