1
2
3
4
5
6
7
8
9
10
public static void main(String[] args) {
    //创建数组的第一种方法,指定数组长度
    int[] arr1 = new int[6];
    //创建数组的第二种方法,创建并初始化
    int[] arr2 = {1, 2, 3, 4};
    //创建数组的第三种方法
    int[] arr3 = new int[]{1, 2, 3, 4, 5};
}
      Post
    
    
    
      
      
    
    Cancel
  Java中创建数组的三种方式
      
        
        This post is licensed under 
        
          CC BY 4.0
        
         by the author.
      
    
    
  