Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can anyone talk me through 3d array

 
Lindsey Ship
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, if my question is not allowed,please forgive me,I don't want to offend any one.
I need to do a 3d array, I have tried but always get stuck! I want to learn java so I am not asking for the code.
What i would like if some one to talk me through it step by step, by e-mail.
I will do all the work, describe the array,and create it.But step by step if you can confirm i am right at each stage. That way if I make a mistake along the way you can stop me. Allowing me to learn this problem. Again I stress I'm not asking for the code, just for some one to guid me
please.
If this is not possible I will understand
and I wish you all and your families good luck and good health, as you have answered question for me in the pass , which I will always be gratefull.
Lindsey
Lindsey_ship@yahoo.com.uk
 
Junilu Lacar
Bartender
Pie
Posts: 7328
45
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Lindsey,
Java doesn't really have multi-dimensional arrays. You can, however, have arrays within arrays, within array...etc. The syntax is only slightly different from other languages that support multi-dimensional array.
// normal array of int with six elements
int[] normal = {0, 1, 2, 3, 4, 5};
// simulate two dimensions: the following
// shows an array that has three element,
// with each element being an array with
// two int elements
int[][] twoDims = {{0, 1}, {2, 3}, {4, 5}};
The leftmost array index refers to elements in the outermost array and the rightmost array index refers to elements in the innermost arrays. Thus,
twoDims[0][0] is 0
twoDims[0][1] is 1
twoDims[1][0] is 2
twoDims[1][1] is 3
twoDims[2][0] is 4
twoDims[2][1] is 5
You can extend this pattern to simulate 3 or more dimensions.
HTH
 
Lindsey Ship
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Junilu, for a fast response
I will keep trying later to do it.
Lindsey.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic