This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes How do I fill a 2d array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How do I fill a 2d array" Watch "How do I fill a 2d array" New topic
Author

How do I fill a 2d array

Joana Silva
Greenhorn

Joined: Feb 28, 2009
Posts: 5
hello , so I have String[][] tmp = new String[800][800];

how do I feel him without the manual [0][0]?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38412
    
  23
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

Joined: Oct 19, 2007
Posts: 4
You must fill the array either by row-wise or column-wise processing.
Amir Iqbal
Ranch Hand

Joined: Jun 23, 2007
Posts: 97
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,


i am Java +ve Now !
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10268
    
    8

Yuva Java wrote:


Please check your private messages for an important administrative matter


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How do I fill a 2d array