• Post Reply Bookmark Topic Watch Topic
  • New Topic

object finalize method doubt  RSS feed

 
sambasivarao laghuvarapu
Greenhorn
Posts: 9
  • 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
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JVM will ignore any exception throw in finalize method.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!