1.try表达式
- 定义
try{}
catch{}
finally{}
//例子
try{
Integer.parseInt("dog")
}catch {
case _ => 0
}finally {
println("always be printed")
}
2.match表达式
exp match{ case p1 =>val1 case p2 =>val2 ... case _ => valm } val code=1 code match{ case 1 =>"one" case 2 =>"two" case _ =>"other" }