This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes object finalize  method doubt 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 "object finalize  method doubt" Watch "object finalize  method doubt" New topic

object finalize method doubt

sambasivarao laghuvarapu

Joined: Jun 07, 2007
Posts: 9
class A{
public void finalize(){
int i=8/0;

public static void main(String[] args){
A a=new A();
if the garbage collector call the finalize method.what will happen.please explain.
Gaurav Bhatia
Ranch Hand

Joined: Jan 01, 2007
Posts: 49
As per java documentation,
"Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored."

~Gaurav<br />SCJP5
antonio ciambellari

Joined: Sep 27, 2007
Posts: 11
The JVM will ignore any exception throw in finalize method.
I agree. Here's the link:
subject: object finalize method doubt
It's not a secret anymore!