0

What different two dimensional array?

uint[5][] ipadPrice;
uint[][5] macPrice;

2 Answers 2

1

For uint[5][] ipadPrice, the first dimension is [5], which is fixed (only 5 elements can be stored here), while the second dimension is [], which is dynamic.

For uint[][5] macPrice, the first dimension is [], which is dynamic, while the second dimension is [5], which is fixed (only 5 elements can be stored here).

You can stored an arbitrary number of elements in a dynamic dimension.

Both of your examples are called mixed-sized two-dimensional array.

0

The notation [] means that the array has dynamic length - its length is not preset. Therefore the first array is a two-dimensional array where the first dimension has dynamic length and the second has 5 elements. The second array is other way around.

Dynamic length means that there can be any amount of entries in the array. Specifying [5] means there are exactly 5 entries.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.