What does parseInt do exactly?

2020-05-10 08:28发布

问题:

What does parseInt do exactly?

回答1:

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);


标签: java parsing int