M
Myriam Abramson
Is there a way of "redefining" the storage allocated to arrays so that you can use them as one-dimensional or two-dimensional?
Myriam said:Is there a way of "redefining" the storage allocated to arrays so that you can use them as one-dimensional or two-dimensional?
Myriam said:Is there a way of "redefining" the storage allocated to arrays so that you can use them as one-dimensional or two-dimensional?
Myriam said:Is there a way of "redefining" the storage allocated to arrays so that you can use them as one-dimensional or two-dimensional?
String[]{"and","here","is","another","single D","array"};You could just make another 2d array to "Hold" your 1d arrays
such as...
String[] my_first_array = new String[] {"this","is","my","first","single D","array"};
String[] my_second_array = new
String[][] my_2d_array = new String[][]{ my_first_array, my_second_array};
System.out.println(my_2d_array[0][3] + " or " + my_2d_array[1][3]);
my_first_array[3] = "worst";
System.out.println(my_2d_array[0][3] + " or " + my_2d_array[1][3]);
....
$> java [above]
first or another
worst or another
$>
The last two lines show, my_2d_array only references the original arrays so the two may be
used together [in 1d or 2d fashion] without duplicating the actual data...
Rob
Is there a way of "redefining" the storage allocated to arrays so that you can use them as one-dimensional or two-dimensional?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.