length.java

来自「it is a good tool to help you study java」· Java 代码 · 共 12 行

JAVA
12
字号
//this programe demonstrates the length array menber
class Length{
public static void main(String args[]){
int a1[]=new int [10];
int a2[]={3,5,7,1,8,99,55,-10};
int a3[]={4,3,2,1};
System.out.println("length of a1 is "+a1.length);
System.out.println("length of a2 is "+a2.length);
System.out.println("length of a3 is "+a3.length);
}
}
//数组在java中是作为类/对象来实现得.可以看出每个数组得大小都被显示出来了,需要记住得是:length//的值和数组的实际使用的元素个数没有关系,length仅仅反映了数组所能够包含的元素个数

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?