NumberFormatException

后端 未结 2 1208
面向向阳花
面向向阳花 2021-01-26 01:13

I\'m trying to develop an app that will take a number from the dial pad and call another number instead. But i get a number format exception on the phonenumber i want to call. <

相关标签:
2条回答
  • 2021-01-26 01:49

    2156689451 is too big for an int (which range from -2^31≈-2,147E9 to +2^31-1≈2,147E9, whereas your number is ~2,15E10)

    Use long instead of int...

    0 讨论(0)
  • 2021-01-26 01:53

    That's because 6768886877 is too big of a number for an int.

    Use a long instead.

    long checkNumber = 0l;
    
    try{
      checkNumber = Long.parseLong (phoneNumber);
    }
    catch (NumberFormatException e)
    {
      e.printStackTrace();
    }
    
    0 讨论(0)
提交回复
热议问题