Leonardo Pereira wrote:
Leonardo Pereira wrote:Hi. I could not understand the exercice 10, chapter 3 from K&B.
Please, take a look in the code below:
According to the book, when "//do stuff" is reached, five objects were created and two are elegible for GC.
In my opinion there are 3 objects that are elected to GC. Did I missing anything?
Thanks in advance,
Leo
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
OCPJP 6
Scott Gordon Sutherland wrote:
Dozens [] da = new Dozens[3];
//One object is created (ie a single Array 'da' with four index options (ie [0,1,2,3]),...
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Thorsten Schneider wrote:You miss the creation of objects of type int[] whenever an instantiation of type Dozens occurs. These int[] can no longer be reached, if you can't reach the object referencing them.
So, let's start this over:
Thorsten Schneider wrote:You miss the creation of objects of type int[] whenever an instantiation of type Dozens occurs. These int[] can no longer be reached, if you can't reach the object referencing them.
So, let's start this over:
nitin sethi wrote:Hi Aditya,
I hope the below explanation clears your doubt. If a class contains an object as its instance member, creating that class's object creates one more object corresponding to that instance member.
Regards,
Nitin Sethi
OCPJP
nitin sethi wrote:Hi Aditya,
I hope the below explanation clears your doubt. If a class contains an object as its instance member, creating that class's object creates one more object corresponding to that instance member.
Regards,
Nitin Sethi
Christian Joseph wrote:
hey another Question what if the Integer "obj" instance variables is not declared. will it create an object if i type "new IntObjClass"
Christian Joseph wrote:so what happened here is obj is pointing two objects(new IntObjClass and Integer Object) on the HEAP. so once the obj is declared null, the two are left on the blackhole(i prefer this term instead of heap )
TY MS NAVEEN MADARAPU!
OCPJP
Christian Joseph wrote:...will it create an object if i type "new IntObjClass"
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Don't get me started about those stupid light bulbs. |