Syntax for creating a two-dimensional array
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Consider: int[][] multD = new int[5][]; multD[0] = new int[10]; Is this how you create a two-dimensional array with 5 rows and 10 columns? I saw this code online, but the syntax didn't make sense. 回答1: Try the following: int[][] multi = new int[5][10]; ... which is a short hand for something like this: int[][] multi = new int[5][]; multi[0] = new int[10]; multi[1] = new int[10]; multi[2] = new int[10]; multi[3] = new int[10]; multi[4] = new int[10]; Note that every element will be initialized to the default value for int , 0 , so the above