OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
Harikrishna Gorrepati wrote:Hi Abimaran, I am referring about "date" at Line 10 and you are referring "d" at Line 5.
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
Harikrishna Gorrepati wrote:K &B says that "date" reference is not eligible for Garbage collection because it returns on Page 259.
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Harikrishna Gorrepati wrote:K &B says that "date" reference is not eligible for Garbage collection because it returns on Page 259.
SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Abimaran Kugathasan wrote:
Harikrishna Gorrepati wrote:K &B says that "date" reference is not eligible for Garbage collection because it returns on Page 259.
Garbage Collection can only be applied to objects not to reference variables. I think, the means the object which referred by the variable date.
OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
Harikrishna Gorrepati wrote:
What you are trying to achieve? --> I want to nullify so that it will be GCed..Where can I do ? How can I do ?
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
Harikrishna Gorrepati wrote:I thought the same but K& B says, "date" reference is not eligible for Garbage collection because it returns.
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
Harikrishna Gorrepati wrote:Hi prasad, I got what you are saying. But my question is, How can we make Date object null referenced by "date" reference variable at line 10.
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
Harikrishna Gorrepati wrote:But my question is, How can we make Date object null referenced by "date" reference variable at line 10.
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
SCJP 6 [86%], OCPWCD [84%], OCEJPAD [83%]
If you find any post useful, click the "plus one" sign on the right
Prasad Kharkar wrote:wel Abimaran's post is perfect now
plus one to the post
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Abimaran Kugathasan wrote:This is what I can say,
A Date object is created on the 10th line, and it's referred by the method local variable date. The object is returned to the caller on the 13th line, so the object is noe referred by another local variable d. After the completion of the method getDate() the stack used for the method is erased, so the local variable is no more there. But, since the object is on the heap and it's referred by another variable d in another method, you can't make the object eligible for GC. By making the variable d null, there is no more variables to refer the object. So, it's eligible for GC.
Within the getDate() method, you can't make the object null, because, your method intention in to create a Date object and returned it to the caller. And further, you can't make the local variable date null, because, if you want to do that, you have to do it after the return statement. But, no statements can't be after a control statement[return, etc].
OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
Harikrishna Gorrepati wrote:Thanks Abimaran. I am clear now.
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Consider Paul's rocket mass heater. |