Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.lang.Thread.UncaughtExceptionHandler;

public class Main {
    public static void main(String[] args) {
        Thread thread = new Thread() {
            public void run() {
                throw new NullPointerException();
            }
        };
        thread.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
            @Override
            public void uncaughtException(Thread arg0, Throwable arg1) {
                arg1.printStackTrace();
            }
        });
        thread.start();
    }
}