File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Object reference array assignment

 
Shiva Mohan
Ranch Hand
Posts: 484
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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: 2399
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a3[0][1] is a 1-dimensional array.
 
Shiva Mohan
Ranch Hand
Posts: 484
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rahuldf sharmadf
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it is one dimensional array
 
Shiva Mohan
Ranch Hand
Posts: 484
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At which line,a3 three-dimensional array is changed to one-dimensional.Please explain if possible?
 
Henry Wong
author
Marshal
Pie
Posts: 20820
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 )
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic