📜  字符串到 int 错误 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:47.057000             🧑  作者: Mango

代码示例1
To check if a string is an integer, just attempt to parse it as an integer and if an exception is thrown, then it is not an Integer. Integer. parseInt(command) will give you NumberFormatException if the String is not valid. It is possible in your code if the user enters 'S' or 'E' which cannot be parsed to int value