parseInt到底能做什么? [英] What does parseInt do exactly?

查看:93
本文介绍了parseInt到底能做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

parseInt到底能做什么?

What does parseInt do exactly?

推荐答案

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

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

这篇关于parseInt到底能做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆