• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I fill a 2d array

 
Joana Silva
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello , so I have String[][] tmp = new String[800][800];

how do I feel him without the manual [0][0]?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49845
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no such thing as a 2D array; what you have as an array of arrays.

tmp = new String[][]{{"word", "wordd", "worddd"}, {"wordddd", "worddddd"}}; maybe?

You may be able to obtain the contents for the array from a List.

There are bound to be other ways: anybody else?
 
Yuvamurugan Pugazhenthi
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You must fill the array either by row-wise or column-wise processing.
 
Amir Iqbal
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
unfortunately i am unable to understand your question.
by the way in my opinion

1) when you create the object of an array and give the the size (ie 800 * 800 in your case) it is automatically initiazed with null at every index.
2) and second option is you just need one loop from index zero to 800 and fill up any string at all the indices.

right

Regards,

 
Maneesh Godbole
Saloon Keeper
Posts: 11096
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yuva Java wrote:


Please check your private messages for an important administrative matter
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic