public class ExceptionV4CatchingMultipleTypes {
    public static Person retornoNulo() {
        return null;
    }
    public static void main(String[] args) {
        try {
            System.out.println("Me pregunto por donde petara. :-?");
            if (((int)(Math.random()*2)) == 1) {
                Person p = retornoNulo();
                System.out.println("Person: " + p);
                System.out.println("Person's first name: " + p.getFirstName());
            } else {
                int a[] = {1, 2, 3};
                System.out.println("Access element one :" + a[1]);
                System.out.println("Access element two  :" + a[2]);
                System.out.println("Access element three  :" + a[3]);
            }
        } catch (ArrayIndexOutOfBoundsException|NullPointerException e) {
            System.out.println("Ups! Array o Pointer Exception:\n\t" + e);
            // Since Java 7 you can handle more than one exceptions
            // using a single catch block, this feature simplifies the code.
        }
        System.out.println("Me recupero y no peto. :-)");
    }
}
