return and break
break is used to exit (escape) the for-loop, while-loop, switch-statement that you are currently executing.
return will exit the entire method you are currently executing (and possibly return a value to the caller, optional).
-
break是跳出当前的循环体像是for循环、while循环或是switch语句。
-
return是跳出当前的函数,并且大部分情况会有返回值。

浙公网安备 33010602011771号