File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Objects created on Heap

 
ramya ray
Ranch Hand
Posts: 101
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain how many objects are created on heap in a multi dimension array.
for eg:

int [][]a = new int[3][]; //how many objects will be created on heap?
and for
int [][]a = new int[3][5]; //how many objects will be created on heap?

Please explain.
Thanks.
 
Scott Johnson
Ranch Hand
Posts: 518
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


1 (A single array is created. That array is an object stored on the heap. The array has three null references.)



4 (An array with references to three other arrays. Each array is an object on the heap.)
 
ramya ray
Ranch Hand
Posts: 101
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for replying ,I got it
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic