On Oct 17, 12:13 am, DimiBy <dimiby.alle...@gmail.com> wrote:
> Hi
>
> Explain to me please. Why from code
>
> // Declare and create two dimensional int array whose size is 10 by 5
>         int[][] ages = new int[10][5];
>
>         // Display the number of rows and columns
>         System.out.println("ages.length = " + ages.length);
>         System.out.println("ages[1].length = " + ages[1].length);
>
> ages.length will be 10 and ages[1].length will be 5? I thought that
> lenght of array is 10*5
>
> Cant undestand.  Help!
In Java there is no notion of n-dimensional array as such. Any n-
dimensional array is a cascade of n nested arrays, so that when you
ask for the dimension of the m-th member of the array you get the
dimension of an array constitued of the uni-dimensional array of this
m-th member.
An example:
if myObject is defined as: myObject[][][][] =  new myObject[3][5][4][7]
[12];
then:
myObject.length= 3
myObject.myObject.length = 5
myObject.myObject.myObject.length = 4;
...
exactly as it is defined in the second member of the statement.
This is different of the mathematical dimension of the global array.

Michèle Garoche

-- 
To post to this group, send email to javaprogrammingwithpassion@googlegroups.com
To unsubscribe from this group, send email to 
javaprogrammingwithpassion+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to