• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

array

 
Shalini Srivastav
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I drew this 3d array to know how will it look.Do you think is it correct?
untitled.JPG
[Thumbnail for untitled.JPG]
 
Nam Ha Minh
Ranch Hand
Posts: 502
Eclipse IDE Firefox Browser Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that's correct!
 
Yogesh Gnanapraksam
Ranch Hand
Posts: 133
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
[Thumbnail for 3-dimension-array.png]
3-D array
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The concept what you are thinking is right...
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21016
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok.So it is misleading to say 'nth dimension' ,probably the term 'nth dimension' applies to mathematical model ..etc.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic