What does parseInt do exactly?

后端 未结 1 720
被撕碎了的回忆
被撕碎了的回忆 2021-01-29 14:44

What does parseInt do exactly?

1条回答
  •  无人及你
    2021-01-29 14:57

    A String cannot be used like an int. With parseInt you can convert a string to an 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);
    

    0 讨论(0)
提交回复
热议问题