Java for Programmers: Lab 12

Exception Handling Example

package com.annedirkse;

public class ExceptionExample { public static void main(String[] args) {
try {
Object o = null;
o.toString();
}
catch(NullPointerException e) {
System.out.println("Null Pointer Exception");
}
catch(Exception e) {
System.out.println("Exception"); }
finally {
System.out.println("Hi there, I am Finally");
}
System.out.println("Got here....");
}
}