【发布时间】:2018-12-09 21:24:38
【问题描述】:
-
在数组中,我们可以这样初始化:
int[] arr = {1, 2, 3, 4, 5}; -
但是对于二维数组,为什么下面的不正确?
public class Main { public static void main(String[] args) { int[][] arr = new int[3][]; arr[0] = new int[]{1,2,3}; //This is the correct way arr[0] = {1,2,3}; // ->Why this is not right? } }
【问题讨论】:
-
您是否正在寻找“因为 java 语言规范”以外的答案?