Win a copy of Kotlin in Action this week in the Kotlin forum!
programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering Languages Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# array

Shalini Srivastav
Ranch Hand
Posts: 86

I drew this 3d array to know how will it look.Do you think is it correct?
untitled.JPG

Nam Ha Minh
Ranch Hand
Posts: 515
Yes, that's correct!

Yogesh Gnanapraksam
Ranch Hand
Posts: 133
• 1
I have this kind of picture in mind when I think of 3-d arrays. I am not sure whether the ordering is important...
3-dimension-array.png

Campbell Ritchie
Marshal
Posts: 55698
163
• 1
There is no such thing as a 3D array in Java. that is an array of arrays of arrays. I cannot understand your diagram.

Yogesh Gnanapraksam
Ranch Hand
Posts: 133
we are talking about the same thing..array of arrays or multidimensional array ..

From the documentation

You can also declare an array of arrays (also known as a multidimensional array) by using two or more sets of square brackets, such as String[][] names. Each element, therefore, must be accessed by a corresponding number of index values.

Jo Joseph
Greenhorn
Posts: 26
The concept what you are thinking is right...

Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
array[1] =(index0 has)> array[1] =(index0 has)> array[0] so, array of array(s) of array(s) ... easy to understand ? :P

Shalini Srivastav
Ranch Hand
Posts: 86
Array of arrays doesn't clear dimension, how anyone can mention that this is [][] or [][][] ? In your term both are array of arrays.so we student like to use 2D for [][] and 3D for [][][].

Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
I know it is common practice to say n D(dimension) . but at least for me it is always clear array holds arrays rather than 2D.

Rameshwar Soni
Ranch Hand
Posts: 247
• 1
Shalini Srivastav wrote:Array of arrays doesn't clear dimension, how anyone can mention that this is [][] or [][][] ? In your term both are array of arrays.

Arrays of arrays----------[][]

arrays of arrays of arrays -----------[][][] and so on
Shalini Srivastav wrote: so we student like to use 2D for [][] and 3D for [][][].

I too used to tell them the way you are telling, but i have seen Campbell, Fred etc always telling that its incorrect to tell them 2-D or 3-D etc, so i think we should learn properly and more importantly correctly.

Because when we would face interviews, what we tell as a student won't count but the correct things would count and matter.

Henry Wong
author
Sheriff
Posts: 23283
125
Rameshwar Soni wrote:
Shalini Srivastav wrote: so we student like to use 2D for [][] and 3D for [][][].

I too used to tell them the way you are telling, but i have seen Campbell, Fred etc always telling that its incorrect to tell them 2-D or 3-D etc, so i think we should learn properly and more importantly correctly.

Because when we would face interviews, what we tell as a student won't count but the correct things would count and matter.

Another way to think about it ... the concept of a 3D array imply that there is such a thing -- meaning a type that is a 3D array. And there isn't....

may look like a single object, and hence, a 3D array object is being instantiated. However, the code is syntactic sugar. Under the hood, the compiler is generating code that looks more like this....

It is, under the hood, implemented as array of arrays. And not the traditional matrix multidimensional array as implemented in languages like C / C++.

Henry

Campbell Ritchie
Marshal
Posts: 55698
163
You can do things with arrays of arrays which you can’t do with real multidimensional arrays. For example, you can alter the size of one of its elements by re‑assigning it, which you can’t do with a true multidimensional array.
Neither the link you quoted, nor the real documentation (the Java Language Specification) says 2D array, 3D array, or similar. In fact, in the sentence after what you quoted, it says
In the Java programming language, a multidimensional array is simply an array whose components are themselves arrays.
They are simply using multidimensional for an array of arr...ays, without specifying the number of [] pairs.

Yogesh Gnanapraksam
Ranch Hand
Posts: 133
ok.So it is misleading to say 'nth dimension' ,probably the term 'nth dimension' applies to mathematical model ..etc.

 It is sorta covered in the JavaRanch Style Guide.