Win a copy of Terraform in Action this week in the Cloud forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

K&B unclear statement about arrays

 
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


If you assign an array to a previously declared array reference, the array you're assigning must be the same dimension as the reference you're assigning it to.



What does this mean? I can't get it. Can someone explain this to me !? Some example would be perfect ;)

Thanks all.
 
Ranch Hand
Posts: 310
1
Oracle Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Emanuele Ghe wrote:


If you assign an array to a previously declared array reference, the array you're assigning must be the same dimension as the reference you're assigning it to.



What does this mean? I can't get it. Can someone explain this to me !? Some example would be perfect ;)

Thanks all.



for example if you have some int arrays as follows:



you can only assign arrays if the dimension is same. You can assign a one dimensional array to another one dimensional array, NOT to a two dimensional array.

 
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mate,

It simply means that,

One dimensional array can only be assigned to one dimensional array.
Two dimensional to two dimensional. You can't do something like that, if you have a two dimensional array and you assign it to one dimensional array.
It will be compile time error.

Hope this helps,
 
Emanuele Ghe
Ranch Hand
Posts: 111
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I feel so stupid, I am so sorry for this dumb question.

In fact I thought it was about the dimension inside square brakets...

Sorry, thanks for answering my s**tty question in a detailed way ;)
 
Prithvi Sehgal
Ranch Hand
Posts: 774
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mate,

No question is stupid as long as we are learning.

Best Regards,
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic