Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sample code to test exception catching in JAVA. This code demonstrates how to build a mapper function to find which user defined exception was thrown.
// this code was tested using java ide from tutorials point
// see the running code on
import java.lang.*;
public class SampleExceptionCatching{
public static void main(String []args){
System.out.println("Hello World");
throw new SampleException();
}catch(Exception e){
System.out.println("exceptionCatching = "+e.getClass());
class SampleException extends Exception{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.