• 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:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

array of arrays

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I did a code that have two arrays, one I call array1 and the other array2, two of them two-dimensional. What's the difference between the 2 implementations bellow? Is there any difference? Because I've never seen this kind of implementation where you inicialize the array without passing the number of colums: byte[][] array12 = new byte[3][];
I saw this only in the book about certification Java.



Being more especific...

Is this



the same of it?


Internaly that declaration byte[][] array1 = new byte[3][2]; creates an array of arrays?

Thank you very much
 
author & internet detective
Posts: 42151
937
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Bruno,
Yes. THose two are equivalent. The first is obviously easier to read and write.

The reason you only see the later in a certification book is that people don't generally use that approach in real life. The certification is testing a deeper understanding to see if you know what the first approach (convenience shortcut) is doing.
 
Bruno Sant Ana
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Jeanne,

Thanks for the explanation, I understood it. If appears one more doubt related to this subject I'll post here.
 
reply
    Bookmark Topic Watch Topic
  • New Topic