Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Length of Multidimensional Arrary

Reply
Thread Tools

Length of Multidimensional Arrary

 
 
Asad Kazmi
Guest
Posts: n/a
 
      06-20-2004
hi,

I want to know that in multidimensional array lenght of array is calculated
like this procedure or any other

Test[x][y] row (x)+column(y) = z Is this correct ?

Regards
Asad Kazmi


 
Reply With Quote
 
 
 
 
VisionSet
Guest
Posts: n/a
 
      06-20-2004
"Asad Kazmi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> hi,
>
> I want to know that in multidimensional array lenght of array is

calculated
> like this procedure or any other
>
> Test[x][y] row (x)+column(y) = z Is this correct ?
>


In Java there is no such thing as a multidimensional array.

int[][] ints // is an array of arrays.

Length can only ever be attributed to one of those arrays.

So for int[][] x = new int[4][3];

There are 4 arrays of length 3 and one array of arrays of length 4

syntactically as:

int length1 = x.length; // ==4
int length2 = x.length[0]; // ==3
int length2 = x.length[1]; // ==3
int length2 = x.length[2]; // ==3

Note that the arrays do not need to be all the same length:

int[][] y = new int[4][];
y[0] = new int[1];
y[1] = new int[2];
y[2] = new int[3];

int length1 = y.length; // ==4
int length2 = y.length[0]; // ==1
int length2 = y.length[1]; // ==2
int length2 = y.length[2]; // ==3

HTH
--
Mike W


 
Reply With Quote
 
 
 
 
Asad Kazmi
Guest
Posts: n/a
 
      06-20-2004
Thanku Mike,


<snip>

> In Java there is no such thing as a multidimensional array.
>
> int[][] ints // is an array of arrays.
>
> Length can only ever be attributed to one of those arrays.
>
> So for int[][] x = new int[4][3];
>
> There are 4 arrays of length 3 and one array of arrays of length 4
>
> syntactically as:
>
> int length1 = x.length; // ==4
> int length2 = x.length[0]; // ==3
> int length2 = x.length[1]; // ==3
> int length2 = x.length[2]; // ==3
>
> Note that the arrays do not need to be all the same length:
>
> int[][] y = new int[4][];
> y[0] = new int[1];
> y[1] = new int[2];
> y[2] = new int[3];
>
> int length1 = y.length; // ==4
> int length2 = y.length[0]; // ==1
> int length2 = y.length[1]; // ==2
> int length2 = y.length[2]; // ==3
>
> HTH
> --
> Mike W
>
>



 
Reply With Quote
 
Roedy Green
Guest
Posts: n/a
 
      06-20-2004
On Mon, 21 Jun 2004 03:15:43 +0500, "Asad Kazmi" <(E-Mail Removed)>
wrote or quoted :

>I want to know that in multidimensional array lenght of array is calculated
>like this procedure or any other
>
>Test[x][y] row (x)+column(y) = z Is this correct ?


I don't understand your notation or your question.

To understand how Java finds element [x][y] see
http://mindprod.com/jgloss/matrix.html

I acted this out several times at Colorado Conferences racing
breathlessly around the room to demonstrate what a production it is.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JDBC Arrary for out parameter in Oracle jacksu Java 0 07-13-2007 02:11 PM
variable size of an arrary ottawajn C++ 7 12-08-2006 07:52 PM
why arrary with size of zero? Mockey Chen C Programming 2 11-21-2005 03:51 PM
sizeof arrary Nan Li C++ 3 10-03-2005 11:10 AM
value[0] lost in an arrary. Jacob C++ 1 12-23-2004 02:41 PM



Advertisments