NumberFormatException when converting Integer String in Java

前端 未结 4 1576
轻奢々
轻奢々 2021-01-19 13:58

I declare this variable:

private String numCarteBancaireValide=String.valueOf(((Integer.parseInt(Config.NUM_CARTE_BANCAIRE_VALIDE)   ) + (Integer.parseInt(\"         


        
4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-19 14:47

    The 4111111111111111 (which most likely is the value of Config.NUM_CARTE_BANCAIRE_VALIDE) overflows the Integer type.

    Better try with:

    //if you need a primitive
    long value = Long.parseLong(Config.NUM_CARTE_BANCAIRE_VALIDE); 
    

    or

    //if you need a wrapper
    Long value = Long.valueOf(Config.NUM_CARTE_BANCAIRE_VALIDE); 
    

提交回复
热议问题