Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Usage of Throwable

 
Siva kandasamy
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi There,
Can you tell me the usage of Throwable.
What it means here.
protected void finalize() throws Throwable {
System.out.println("Frog finalize");
if(DoBaseFinalization.flag)
super.finalize();
}
Thanks
siva
 
Greg Charles
Sheriff
Posts: 2989
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Throwable is the base class of exceptions and errors that can occur. In this case, it is part of the declaration (throws Throwable) meaning that an exception or error can (but not necessarily will) occur during the call to finalize. This declaration is important, because when an exception occurs in a method, the method stops running, and the exception is passed to the caller of the method. Declaring it gives the calling method a heads up of what may be coming. It can either catch the exception (with a catch block) or declare that it will throw it up to its calling method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic