具有不同长度的二维数组(Java) [英] Two dimensional array with different lengths (Java)
本文介绍了具有不同长度的二维数组(Java)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有机会在第二维中创建具有不同长度的二维数组?例如这样的
Is there an opportunity to create two dimensional Arrays with different lengths in the second dimension? For example like this:
[true] [true] [true]
[true] [true] [true]
[true]
[true] [true] [true] [true] [true]
[true] [true] [true] [true] [true]
最好不要创建其他类(例如存储桶),也不知道数组的实际长度.
Preferably without creating another class (like buckets) and without knowing the actual length of the array.
推荐答案
是的,二维数组中的数组没有相同的大小.例如:
Yes, arrays in a 2D array don't have the have same size. E.g.:
boolean[][] twoDimensionalArray = new boolean[3][];
twoDimensionalArray[0] = new boolean[]{true, true, true};
twoDimensionalArray[1] = new boolean[]{true};
twoDimensionalArray[2] = new boolean[]{true, true, true, true, true};
这篇关于具有不同长度的二维数组(Java)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文