---
title: "Java手动抛异常"
author: "BlueCore"
date: "2009-10-12T09:10:09Z"
tags: []
slug: "java"
draft: false
lastmod: "2009-10-12T09:10:09Z"
id: 485726
url: "https://bluecore.iteye.com/blog/485726"
---

想不到居然忘了如何自动抛出异常，汗，幸好有阿润帮忙，so record it。



```java

public class A {

    /**
     * @param args
     */
    public static void main(String[] args) {
        try{
            throw new NullPointerException();//此行会抛出NullPointedException
        }
        catch(NullPointerException e){
            System.out.print("1");
        }
        catch(RuntimeException e){
            System.out.print("2");
        }
        finally{
            System.out.print("3");
      } 
    }
}

```