Converting String to Int in Android, JSON

This question already has an answer here:

  • How do I convert a String to an int in Java? 30 answers

  • As simple as:

    int i = Integer.parseInt(yourString);
    

    Or, for floats:

    float f = Float.parseFloat(yourString);
    

    You can use

     int value = Integer.parseInt(Budget);
    

    http://docs.oracle.com/javase/7/docs/api/java/lang/Integer.html#parseInt(java.lang.String)

    If Budge t is not valid int , it throws a NumberFormatException .

      try {
           int value = Integer.parseInt(Budget);
      }catch(NumberFormatException e) {
           e.printStackTrace();
      }
    

    将您的字符串值传递给Integer类的parseInt()方法...您将获得给定字符串值的转换值。

    int budget = Integer.parseInt(budget_event);
    
    链接地址: http://www.djcxy.com/p/20928.html

    上一篇: 获取关于输入类型的信息(主要参数)

    下一篇: 在Android,JSON中将字符串转换为Int