一:return语句总是用在方法中,有两个作用:
一个是返回方法指定类型的值(这个值总是确定的),
private String gets(){
String s = "qw789" ;
return s ;
}
一个是结束方法的执行(仅仅一个return语句)。
还有一种,为了进入finally,其实也是为了结束程序但不是马上就要结束程序,
private void run(){
try{
if ( s == null ){
// goto finally
return ;
}
System.out.println( "haha" ) ;
}
catch(Exception e){
}finally{
System.out.println( "clear something" ) ;
}