Laky Laky - 1 year ago 71
Java Question

Are 3D arrays better than other types of arrays in Java?

I am new to Java and I saw a video about 2D arrays online. But what about 3D arrays?

Is it possible to make a 3D array in Java? If so, how can this be done. Also, would using 3 separate 1D arrays (that are linked together) be equivalent to using 1 3D array? Finally, what is the efficiency of traversing through a 3D array?

Answer Source

Making a 3D array is quite possible in Java. It's as simple as declaring the type T[][][] array;. Three separate 1D arrays are not equivalent to one 3D array. You would need n 2D arrays to be equivalent to one 3D array. The efficiency of traversing a 3D array is practically O(n³).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download