File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

object finalize method doubt

 
sambasivarao laghuvarapu
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
class A{
public void finalize(){
int i=8/0;

}
public static void main(String[] args){
A a=new A();
a=null;
System.gc();
}
}
if the garbage collector call the finalize method.what will happen.please explain.
 
Gaurav Bhatia
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As per java documentation,
"Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored."
 
antonio ciambellari
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JVM will ignore any exception throw in finalize method.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic