线程“AWT-EventQueue-0”中的异常java.lang.NumberFormatException:

时间:2023-01-26 21:01:05
public void chooseInterface() {

    int TEMP = Integer.parseInt(SelectInterface.getText());

    if (TEMP > -1 && TEMP < counter) {
        index = 0;
        Enable();
    } else {
        // JOptionPane.showMessageDialog(null, Outside of
        // Range.#interface=0+
        // (counter-1)+".");
        System.out.print("dfdfg");
    }
    SelectInterface.setText("");
}

Error is:

Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: 
    For input string: ""

What is the problem in the code? How to solve this error?

代码中有什么问题?如何解决这个错误?

1 个解决方案

#1


1  

Check empty ("") values for

检查空(“”)值

SelectInterface.getText()

This will give NumberFormatException. Additionally, you can first check for empty value and replace with "0".

这将给出NumberFormatException。此外,您可以先检查空值并替换为“0”。

#1


1  

Check empty ("") values for

检查空(“”)值

SelectInterface.getText()

This will give NumberFormatException. Additionally, you can first check for empty value and replace with "0".

这将给出NumberFormatException。此外,您可以先检查空值并替换为“0”。