标签:on() string 返回值 code 相对 ring rgs ide get
UncaughtExceptionTask task=new UncaughtExceptionTask(); Thread thread = new Thread(task); thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { System.out.println("处理run函数抛出的异常"); System.out.println(t+":"+e); } }); thread.start(); } class UncaughtExceptionTask implements Runnable{ public void run(){ System.out.println(10/0);//throws uncheckerException: ArithmeticException } }
public class ExceptionTest { public static void main(String[] args) { int c=0; try { int a = 3; int b = 0; c=a/b; System.out.println(c); } catch (Exception e) { e.printStackTrace(); } finally { System.out.println("处理了异常: ArithmeticException"); } System.out.println(c); } }
标签:on() string 返回值 code 相对 ring rgs ide get
原文地址:http://www.cnblogs.com/yangyunnb/p/6057874.html