The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

How to store 2D array in another array

I want to generate 30 random 2D array (35 * 35 matrix) and store in single array... Is it possible ????
I have generated 30 random 2D array using the following code . But how to store that 2D (35 * 35 matrix)

Re: How to store 2D array in another array

The same way you initialize a 1D, 2D, and xD array. Please show how you intend to use the array, attempt to initialize it, and ask specific questions about your code. Don't forget to post your code in code tags.

Re: How to store 2D array in another array

@Wizand: Please direct your responses to the OP's question rather than to those who have already responded. Everyone should be able to post their ideas, suggestions, and best efforts here without concern of criticism or derision. Correction, when needed, is certainly acceptable, but it can be done without characterizing a specific member's contribution or that member in a negative way. And in case your comments were meant to be humorous ("I included a smiling emoticon!"), remember than senses of humor vary widely across our international members and humor is not communicated easily in this medium.

Re: How to store 2D array in another array

I think Early students need to build a familiarity with basic programming before moving into OOP. Trying to force them into using classes too soon can lead to frustration. Later in their learning they can move to designing with classes.

Re: How to store 2D array in another array

Originally Posted by GregBrannon

@Wizand: Please direct your responses to the OP's question rather than to those who have already responded. Everyone should be able to post their ideas, suggestions, and best efforts here without concern of criticism or derision. Correction, when needed, is certainly acceptable, but it can be done without characterizing a specific member's contribution or that member in a negative way. And in case your comments were meant to be humorous ("I included a smiling emoticon!"), remember than senses of humor vary widely across our international members and humor is not communicated easily in this medium.

My intentions were certainly not meant to criticize or judge the other replies. As i said, the raw array style is solid and valid in every way. I was trying to bring discussion about the best solution in good spirits and with constructive manner. My apologies for not knowing the proper ways of ways these forums quite yet. I will try to be more considerate in the future.

--- Update ---

Originally Posted by Norm

I think Early students need to build a familiarity with basic programming before moving into OOP. Trying to force them into using classes too soon can lead to frustration. Later in their learning they can move to designing with classes.

That is certainly the way i was brought up, but my opinion on the matter differs a bit. I think ( and as i stated, this is only my -probably quite uneducated- opinion on the matter) it would be worth considering to teach people to think and conceptualize OO-way first, and later learn the actual groundwork of iterating through arrays, pointer math, recursive silliness and all that. The IDEs and tools have developed to the point where kids can make software with drag'n'dropping blocks of logic to a diagram and don't have to worry about array sizes and casting errors directly. So it maybe makes sense to get people to think the "right way" first before using time to fiddle with the details. But maybe this is a discussion for another topic

All in all, your answer definitely answered to the OP's question more directly than mine.