“`” 答:可以转,得处理异常 Integer.parseInt(s) 主要为NumberFormatException:

<span style=""font-size: 1rem;"">1)当 你输入为字母时,也就是内容不是数字时,如 abcd </span>

<span style=""font-size: 1rem;"">2)当你输入为空时 </span>

<span style=""font-size: 1rem;"">3)当你输入超出 int上限时 Long.parseLong(""123"")转换为 long</span>

<pre><code> "“`

Was this helpful?

0 / 0

发表回复 0

Your email address will not be published.