We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › array inside of an array 2d array.
Page Index Toggle Pages: 1
array inside of an array? 2d array. (Read 408 times)
array inside of an array? 2d array.
Mar 16th, 2008, 12:23am
 
pardom my ignorance, but i was wondering can you declare an array inside of an array.

something like this:

String[] words1 = {"words1_0", "words1_1", "words1_2"};
String[] numbers1 = {"numbers1_0", "numbers1_1", "numbers1_2"};

String[][] everyWord = {words1[],numbers1[],numbers1[],words1[]};

then:

everyWord[0][2] = words1_2

or

everyWord[2][1] = numbers1_1

i know this doesn't work, and i'm sure there's a proper/better way, but it's beyond me.

thanks in advance for alleviating my ignorance.

Ken
Re: array inside of an array? 2d array.
Reply #1 - Mar 16th, 2008, 1:42am
 
Like this?

Code:

String[] words1 = {"words1_0", "words1_1", "words1_2"};
String[] numbers1 = {"numbers1_0", "numbers1_1", "numbers1_2"};
String [][] everyWord = {words1, numbers1, {}};
Re: array inside of an array? 2d array.
Reply #2 - Mar 16th, 2008, 2:50am
 
exactly.

i wasn't too far off.

thanks.

Ken
Page Index Toggle Pages: 1