• Post Reply Bookmark Topic Watch Topic
  • New Topic

Filling up 2 dimensional array with all possible value of 0-9  RSS feed

 
Mark Siko
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a 2 dimensional integer array of 16x16 and would like to fill it up with all possible values of 0 to 9. Somehow i just cant get it in my head on the idea of how to do so.

Anyone can provide suggestion on how i go about filling up the array and do something with the int[][] variable only after its filled up?

 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a 2d array is simply an array of arrays. So your first step should be to think about how you would fill a single array.
'
-Hunter
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you want to distribute the values over the array? Because you have 256 array elements and only 10 distinct values. If you want to randomize the numbers check out java.util.Random.nextInt(int).
 
Campbell Ritchie
Marshal
Posts: 56599
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!