Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2014
    Posts
    3
    Rep Power
    0

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

    Hi

    I have Java applet and if I enter really big numbers I get that Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string

    I already have long, NOT int. So I have Long.parseLong. What is better than long?, what can I do?

    Biggest number which I can enter is 123456789123456789.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

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

    The BigInteger class will handle very large numbers.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    Join Date
    Mar 2014
    Posts
    3
    Rep Power
    0

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

    That's it! Thanks! But how? I put this line: import java.math.BigInteger;
    but that won't help.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

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

    that won't help.
    Please explain and copy the full text of any error messages and paste it here.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Join Date
    Mar 2014
    Posts
    3
    Rep Power
    0

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

    Thank You. After Your answer, I just put line "import java.math.BigInteger;" Then I entered "11111111112222222222". Still I will get this error message:


    Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: 11111111112222222222
    at java.lang.NumberFormatException.forInputString(Num berFormatException.java:
    at java.lang.Long.parseLong(Long.java:422)
    at java.lang.Long.parseLong(Long.java:468)


    at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:
    at java.awt.Component.processMouseEvent(Component.jav a:6297)
    at javax.swing.JComponent.processMouseEvent(JComponen t.java:3275)
    at java.awt.Component.processEvent(Component.java:606 2)
    at java.awt.Container.processEvent(Container.java:203 9)
    at java.awt.Component.dispatchEventImpl(Component.jav a:4660)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2097)
    at java.awt.Component.dispatchEvent(Component.java:44 88)
    at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4575)
    at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4236)
    at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4166)
    at java.awt.Container.dispatchEventImpl(Container.jav a:2083)
    at java.awt.Window.dispatchEventImpl(Window.java:2489 )
    at java.awt.Component.dispatchEvent(Component.java:44 88)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:668)
    at java.awt.EventQueue.access$400(EventQueue.java:
    at java.awt.EventQueue$2.run(EventQueue.java:627)
    at java.awt.EventQueue$2.run(EventQueue.java:625)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectio nPrivilege(AccessControlContext.java:
    at java.security.AccessControlContext$1.doIntersectio nPrivilege(AccessControlContext.java:
    at java.awt.EventQueue$3.run(EventQueue.java:641)
    at java.awt.EventQueue$3.run(EventQueue.java:639)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectio nPrivilege(AccessControlContext.java
    at java.awt.EventQueue.dispatchEvent(EventQueue.java: 638)
    at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:269)
    at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:
    at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:
    at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:
    at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:





    So import java.math.BigInteger; is not enough. If Big integer class requires much more code, then
    Big integer class may be too difficult for me. In that case, is there something between Big integer class and Long.parseLong ?

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

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

    Importing a class does NOT change how a primitive like long works.
    The code needs to use the constructor and classes of the BigInteger class to work with large numbers. I don't know of any other way.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 14
    Last Post: 04-08-2011, 07:01 PM
  2. Replies: 5
    Last Post: 04-12-2010, 04:39 PM
  3. Replies: 3
    Last Post: 06-07-2009, 01:14 AM
  4. Replies: 10
    Last Post: 01-29-2009, 09:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •