What does parseInt do exactly?

2020-05-10 08:01发布

What does parseInt do exactly?

标签: java parsing int
1条回答
狗以群分
2楼-- · 2020-05-10 08:43

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);
查看更多
登录 后发表回答