字符串如下,1100000000000002,转换int的时候,出现numberformartException,数字转换异常,是不是字符串太大,转换int 失败,

解决方案 »

  1.   

    远远超出了int的范围。。可以考虑转成BigInteger
      

  2.   


    String str = "1100000000000002";
    System.out.println(Long.parseLong(str));
      

  3.   

    Long.parseLong 转换成long就可以了int是32位的 最大值2147483647
      

  4.   

    BigDecimal应该是最好的,不过这个东东不是很熟悉,因为我动态自加数据,
      

  5.   

    那需要看你的数据范围叻,你给的这个超出叻int的范围  可以考虑使用long,不建议使用BigDecimal这个有精度,没速度的  呵呵、
      

  6.   

    Hi, I think when you run your code, you will get the exception about this error. Query this exception in jdk api and you will find this explain by yourself.It's a good way to improve your ability in program.