Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Two dimensional array and objects count

 
Rajeev Trikha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once we create a two dimensional array with the syntax



Am I right is saying that this will create just one object for garbage collection until we populate a[0] and a[1]?
 
Harpreet Singh janda
Ranch Hand
Posts: 317
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you are right.
 
Ankit Garg
Sheriff
Posts: 9521
22
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajeev Trikha wrote:Am I right is saying that this will create just one object for garbage collection until we populate a[0] and a[1]?

a[0] and a[1] are already initialized as int arrays with 2 elements in that statement. But none of the objects will be eligible for GC as the objects are still referenced by a...
 
Abimaran Kugathasan
Ranch Hand
Posts: 2066
Clojure IntelliJ IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yea. Ankit is correct! Array will be populated, whether it is local or member, doesn't matter!
 
Rajeev Trikha
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks I understand it. I had meant to establish the reality when the array had became eligible for GC by saying a = null;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic