|
-
Jul 18th, 2007, 09:07 AM
#1
Thread Starter
Member
Regarding multidimentional array
Hey, how can i declare and assign a value from one, or both of of it's dimension in a multidimentional array?
starting to this:
Code:
String[][] GroupList = new String[5][5];
??
i've got a book, but it's only a quick summary =/, thanks uhm, and please give me at least an example...
-
Jul 18th, 2007, 02:27 PM
#2
Re: Regarding multidimentional array
You mean something like this:
Code:
String[][] GroupList = new String[5][5];
GroupList[0][0] = "List1 Item1";
for (int i = 0; i < GroupList.length; i++) {
for (int j = 0; j < GroupList[i].length; i++) {
GroupList[i][j] = "List" + i + " Item" + j;
}
}
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jul 19th, 2007, 06:00 AM
#3
Thread Starter
Member
Re: Regarding multidimentional array
ok thanks po...i'll try the code later XD
-
Jul 20th, 2007, 10:01 AM
#4
Re: Regarding multidimentional array
On a pedantic note, Java doesn't support true multidimensional arrays. What you have there is instead a jagged array.
A multidimensional array is stored contiguously, such that, when given given the number and size of the array dimensions, any item in the array can be found using a single pointer expression.
A jagged array is a one-dimensional array of references to other arrays.
Because Java doesn't have pointers, a jagged array, for all intents and purposes, can be considered behaviourally equivalent to a multidimensional array. However, it will not exhibit the same linear performance as a true multidimensional array; the speed of accessing a jagged array is dependent on the level of nesting, since one extra indirection is required per "dimension".
On the positive side, though, they are more flexible, and can be quicker for certain tasks (such as moving columns within the array, which can be accomplished by merely swapping references).
-
Jul 20th, 2007, 10:50 AM
#5
Re: Regarding multidimentional array
Thanks for the note
I found a good article and I'd like to share it with everyone
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|