File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes finalize method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "finalize method" Watch "finalize method" New topic

finalize method

Shanky Sohar
Ranch Hand

Joined: Mar 17, 2010
Posts: 1051

can we call the finalize method for garbage collection explicitly,.....................

SCJP6.0,My blog Ranchers from Delhi
Henry Wong

Joined: Sep 28, 2004
Posts: 20370

You can call the finalize() method, as you can call any method that you have access to -- so if you have access rights, you can call it.

Now... calling the finalize() method doesn't trigger a GC. Calling the finalize() method only causes ... well... the finalize() method to be called.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

It is like the SCJP book says... "The finalize() methods just suggest that those objects should be collect."

[] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
Deepak Bala

Joined: Feb 24, 2006
Posts: 6662

phil sohar wrote:can we call the finalize method for garbage collection explicitly,.....................

Nope. It is a callback method, meaning you dont call it, the JVM does.

SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
I agree. Here's the link:
subject: finalize method
It's not a secret anymore!