【问题标题】:What does parseInt do exactly?parseInt 究竟做了什么?
【发布时间】:2016-02-08 07:50:32
【问题描述】:

parseInt 究竟做了什么?

【问题讨论】:

    标签: java parsing int


    【解决方案1】:

    String 不能像 int 一样使用。使用 parseInt,您可以将字符串转换为 int。

    public class Program {
    
    public static void main(String[] args) {
    
    String value = "1000";
    // Parse with parseInt: the string can be negative.
    int result = Integer.parseInt(value);
    System.out.println(result);
    System.out.println(result + 1);
    

    【讨论】:

      猜你喜欢
      • 2012-07-23
      • 2016-09-10
      • 2023-03-15
      • 2012-10-17
      • 2021-06-04
      • 1970-01-01
      • 2018-07-30
      • 2019-10-06
      • 2021-01-01
      相关资源
      最近更新 更多