aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Two dimensional array and objects count Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Two dimensional array and objects count" Watch "Two dimensional array and objects count" New topic
Author

Two dimensional array and objects count

Rajeev Trikha
Ranch Hand

Joined: Jan 29, 2010
Posts: 85
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]?


Rajeev Trikha (SCJP 6)
Harpreet Singh janda
Ranch Hand

Joined: Jan 14, 2010
Posts: 317

I think you are right.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9305
    
  17

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...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Yea. Ankit is correct! Array will be populated, whether it is local or member, doesn't matter!


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Rajeev Trikha
Ranch Hand

Joined: Jan 29, 2010
Posts: 85
Thanks I understand it. I had meant to establish the reality when the array had became eligible for GC by saying a = null;
 
Don't get me started about those stupid light bulbs.
 
subject: Two dimensional array and objects count