String 转 int,用parse可能会数字转换异常
int foo;try { foo = Integer.parseInt(myString);}catch (NumberFormatException e){ foo = 0;}可以这样处理但是最好这样处理
import com.google.common.primitives.Ints;int foo = Optional.ofNullable(myString) .map(Ints::tryParse) .orElse(0)
来源:https://www.cnblogs.com/xgkwill/p/12454082.html