aspose file tools*
The moose likes Beginning Java and the fly likes array of arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "array of arrays" Watch "array of arrays" New topic
Author

array of arrays

Bruno Sant Ana
Greenhorn

Joined: May 17, 2012
Posts: 27
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
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29287
    
140

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Bruno Sant Ana
Greenhorn

Joined: May 17, 2012
Posts: 27
Hi Jeanne,

Thanks for the explanation, I understood it. If appears one more doubt related to this subject I'll post here.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: array of arrays
 
Similar Threads
how to store data in multi dimenstional arrays
for loop logic problem
David Smalley
Use of a static method with queues
Problem moving columns and rows in 2D array.