java 数组声明方法

 1 //数组
 2 public class Test16{
 3     public static void main(String args[]){
 4         
 5         //声明一:
 6         int [] x;
 7         x = new int[3];//为数组申请内存空间,3个
 8         x[0]=10;
 9         x[1]=20;
10         x[2]=30;
11         //求数组的长度;
12         int len=x.length;
13         System.out.println("变量x的长度:"+len);
14         
15         //声明二:
16         int [] xx=new int[3];//定义一个数组并申请好内存空间
17         xx[0]=10;
18         xx[1]=100;
19         xx[2]=200;
20         
21         //声明三:
22         int [] y=new int[]{10,20,30,40};
23         //int len=x.length;
24         System.out.println("变量y的长度:"+y.length);
25         
26     }
27 }
原文地址:https://www.cnblogs.com/dengyg200891/p/4820642.html