wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets 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: 18496

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

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

Joined: Feb 24, 2006
Posts: 6661

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: http://aspose.com/file-tools
subject: finalize method
Similar Threads
Gc question
why finalize() can't be defined as private?
Finalization Method
difference between finally and finalize()