Monday, 15 August 2011

java - What exactly happens in memory when we allocate an array using an empty curly braces? -


Both of the following examples come back to 0, if we say length :

  int [] [] B = {};  

or

  int [] a = {};  

I think the two objects in general are allocated on the heap: I think in the second case, one object (empty table) type int [] is allocated, but in the first case?

What is happening under the hood under these circumstances?

A 2 dimensional array is an array of arrays and all Arrays are objects themselves

JAVA CODE:

     public static zero main (string [] args) {int [] [] b = {}; Int [] a = {}; }  

Byte code:

  stack = 1, local = 3, args_size = 1 0: iconst_0 1: anewarray # 19 // [] [] . Arrays array - [I 4: Astroere 5: iconage 6: nuearr [int] 9: Return  

No comments:

Post a Comment