• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

array of arrays  RSS feed

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • 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
Sheriff
Posts: 38555
653
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!