首页 文章

线程“AWT-EventQueue-0”中的异常java.lang.NumberFormatException:对于输入字符串:“FALSE”[duplicate]

提问于
浏览
0

这个问题在这里已有答案:

我的代码:

public class BehemothSelectGUI extends javax.swing.JFrame {
private static DBUtil db = new DBUtil();
private static Populate populate = new Populate();
static int WepHitPoints;
static int ShoulderHitPoints;
static int ChestHitPoints;
static int WristHitPoints;
static int HelmHitPoints;
static int WepAttack;
static int HelmDef;
static int ShoulderDef;
static int WristDef;
static int ChestDef;
static int HelmMoveSpeed;
static int WepMoveSpeed;
static int ChestMoveSpeed;
static int ShoulderMoveSpeed;
static int WristMoveSpeed;

private void cmbMothHeadActionPerformed(java.awt.event.ActionEvent evt) {                                          
    String data[][] = db.selectAll("tblBehemoth");

    for (int i = 0; i < data.length; i++) {
        if (data[i][1].equals((String) cmbMothHead.getSelectedItem())) {
            HelmHitPoints = Integer.parseInt(data[i][2]);
            HelmDef = Integer.parseInt(data[i][4]);
            HelmMoveSpeed = Integer.parseInt(data[i][5]); //StackTrace error
            break;
        }
    }

}

错误:

线程“AWT-EventQueue-0”中的异常java.lang.NumberFormatException:对于输入字符串:java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)中的输入字符串:“FALSE”,位于java.lang.Integer.parseInt(Integer . java:580)at atapp.BehemothSelectGUI.cmbMothHeadActionPerformed(BehemothSelectGUI.java:182)atapp.BehemothSelectGUI.access $ 100(BehemothSelectGUI.java:12)at leapp.BehemothSelectGUI的java.lang.Integer.parseInt(Integer.java:615) $ 2.actionPerformed(BehemothSelectGUI.java:78)javax.swing.JComboBox.fireActionEvent(JComboBox.java:1258)javax.swing.JComboBox.contentsChanged(JComboBox.java:1332)javax.swing.AbstractListModel.fireContentsChanged(AbstractListModel)的.java:118)在javax.swing.DefaultComboBoxModel.setSelectedItem(DefaultComboBoxModel.java:93)在javax.swing.DefaultComboBoxModel.addElement(DefaultComboBoxModel.java:131)在javax.swing.JComboBox.addItem(JComboBox.java:716)在leapp.PehemothSelectGUI的leapp.Populate.cmbPop(Populate.java:66) . (BehemothSelectG) UI.java:41)在leapp.HeroSelectGUI.btnChooseMothActionPerformed(HeroSelectGUI.java:170)在leapp.HeroSelectGUI.access $ 000(HeroSelectGUI.java:14)在leapp.HeroSelectGUI $ 1.actionPerformed(HeroSelectGUI.java:78)在使用javax . swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)at javax.swing.AbstractButton $ Handler.actionPerformed(AbstractButton.java:2348)at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)at javax.swing.DefaultButtonModel在javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)在java.awt.Component.processMouseEvent(Component.java:6533)在javax.swing.JComponent中.setPressed(DefaultButtonModel.java:259) . java.awt.Component上的java.awt.Component.processEvent(Component.java:6298)中的processMouseEvent(JComponent.java:3324)java.awt.Component.dispatchEventImpl(Component.java)中的java.awt.Container.processEvent(Container.java:2236) :4889)在java.awt.Component.dispa的java.awt.Container.dispatchEventImpl(Container.java:2294) tchEvent(Component.java:4711)在java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)在java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)在java.awt.LightweightDispatcher.dispatchEvent(Container.java :4466)java.awt.Container.dispatchEventImpl(Container.java:2280)at java.awt.Window.dispatchEventImpl(Window.java:2746)at java.awt.Component.dispatchEvent(Component.java:4711)at java java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)java.awt.EventQueue.access $ 500(EventQueue.java:97)at java.awt.EventQueue $ 3.run(EventQueue.java:709)at java.awt . java.security.ProtectionDomain上java.security.AccessController.doPrivileged(Native Method)的EventQueue $ 3.run(EventQueue.java:703)java.security.ProtectionDomain $ JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)$ JavaSecurityAccessImpl.doIntersectionPrivilege (ProtectionDomain.java:86)java.awt.EventQueue $ 4.run(EventQueue.java:731)at java.awt.EventQueue $ 4.run(EventQueue)的.java:729)在java.security.AccessController.doPrivileged(本机方法)在java.security.ProtectionDomain $ JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)在java.awt.EventQueue.dispatchEvent(EventQueue.java:728)在java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)在java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)在java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)在java.awt.EventDispatchThread .pumpEvents(EventDispatchThread.java:101)在java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)在java.awt.EventDispatchThread.run(EventDispatchThread.java:82)BUILD SUCCESSFUL(总时间:5秒)

我一直在使用Integer.parseInt(data [i] [number]转换器来处理其他变量,但只有这一个会引发错误 .

更新:当我sysoutLine它返回'FALSE' . 我仍然不知道它是如何返回false的,因为我的数据库col 5是数字

System.out.println(data [i] [5]);

1 回答

  • 1

    Integer.parseInt(String str) java文档非常清楚地说明了这一点 .

    抛出:NumberFormatException - 如果字符串不包含可解析的整数 .

    并且 FALSE 不是可解析的整数 .

    所有不一致的形成你的堆栈跟踪:

    例外在线程“AWT-EventQueue-0”中java.lang.NumberFormatException:对于输入字符串:java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)中的“FALSE”

相关问题