Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering Languages Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# Object reference array assignment

Shiva Mohan
Ranch Hand
Posts: 486

I don't get this reference assignment.
My ananlysis about line 5 is,a2[0] and a2[1] are one dimensinal arrays and a1 reference is also one dimensional array.so assignation is valid
My analysis about line 6,a3[0],a3[1],a3[2] are one dimensional array and a2 reference is two dimensional array.i thought it would be invalid.but this one compiles fine .How?Please explain.
My understanding about line 7,a3[0][1] is two-dimensional array and a2 reference is also two-dimensional array.so ithought it would valid.but this statement produce compilee error.Please explain
[ September 18, 2006: Message edited by: Shiva Mohan ]

Keith Lynn
Ranch Hand
Posts: 2409
a3[0][1] is a 1-dimensional array.

Shiva Mohan
Ranch Hand
Posts: 486
Thanks for the reply Keith. In declaration of a3 is an three-dimensional array.Right?
In the statement a3[0][1]=a2;here a3 is two-dimensional array.How come a3 is one-dimensional.Please explain

Greenhorn
Posts: 3
it is one dimensional array

Shiva Mohan
Ranch Hand
Posts: 486
At which line,a3 three-dimensional array is changed to one-dimensional.Please explain if possible?

Henry Wong
author
Sheriff
Posts: 23275
125
Originally posted by Shiva Mohan:
Thanks for the reply Keith. In declaration of a3 is an three-dimensional array.Right?
In the statement a3[0][1]=a2;here a3 is two-dimensional array.How come a3 is one-dimensional.Please explain

a3 is "three-dimensional". a2 is "two-dimension". And a3[0][1] is one dimensional.

Henry

PS... I place the number of arrays in quotes, because technically, Java supports arrays of arrays -- not multidimensional arrays. (but for this debate, it's an okay interpretation.)

Meena R. Krishnan
Ranch Hand
Posts: 178
a3 is a 3-d array of size 3.(line 3 )

a3[0], a3[1],a3[2] each in turn is a 2-d array and each of size 2. (line 6) - since the value of a2 is being assigned to these.

a3[0][0],a3[0][1],a3[1][0],a3[1][1] each in turn is a 1-d array of size 1. ( each carrying the reference to A11 )