📌  相关文章
📜  线程“main”中的异常 java.lang.numberformatexception:对于输入字符串:“” - Java 代码示例

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

代码示例1
int number = 0; // or any application default value
try {
    number = Integer.parseInt(input);
} catch (NumberFormatException nfe) {
    // do whatever you need to do if you get an invalid number
    // you can put the try catch in a loop and keep asking for a 
    // value until you don't get a valid one
    
      // If you want to use the default value in case of an
    // invalid number you can do nothing in here
}