1. try{
    2. }catch{
    3. case ex: ArithmeticException =>{
    4. }
    5. case ex: Exception =>{
    6. }
    7. }
    8. finally{
    9. }

    用throw关键字,抛出一个异常对象。 所有异常都是Throwable的子类型。Nothing是所有类型的子类型 def test():Nothing = { throw new Exception(“error”) }

    java用throws来声明异常,在Scala中用@throws注解来声明异常 @throws(classOf[NumberFormatException]) def test(){ “abc”.toInt }