• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Object reference array assignment

 
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
a3[0][1] is a 1-dimensional array.
 
Shiva Mohan
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it is one dimensional array
 
Shiva Mohan
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
At which line,a3 three-dimensional array is changed to one-dimensional.Please explain if possible?
 
author
Posts: 23923
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.)
 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic