A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/javaexamples/exception_hierarchy.htm below:

How to handle the exception hierarchies in Java

How to handle the exception hierarchies in Java Problem Description

How to handle the exception hierarchies?

Here is the sample diagram of Exception Hierarchies

Solution

This example shows how to handle the exception hierarchies by extending Exception class ?

class Animal extends Exception {
}
class Mammel extends Animal {
}
public class Human {
   public static void main(String[] args) {
      try {
         throw new Mammel();
      } catch (Mammel m) {
         System.err.println("It is mammel");
      }
   }
}
Result

The above code sample will produce the following result.

It is mammel

java_exceptions.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4