哪一个是更快? Integer.valueOf(字符串字符串)或的Integer.parseInt(String s)返回? [英] Which one is faster? Integer.valueOf(String string) or Integer.parseInt(String string)?

查看:201
本文介绍了哪一个是更快? Integer.valueOf(字符串字符串)或的Integer.parseInt(String s)返回?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道哪种方法更快?

I want to know which method is faster?

Integer.valueOf(字符串字符串)的Integer.parseInt(String s)返回

有两种方法之间的任何性能或内存的区别?

Is there any Performance or Memory difference between the two approaches?

我已经看到了<一个href="http://stackoverflow.com/questions/508665/difference-between-parseint-and-valueof-in-java">Difference parseInt函数和的valueOf在Java?中但之间,这并不解释在性能方面的差别。

I have seen Difference between parseInt and valueOf in java? but this does not explains difference in terms of performance.

推荐答案

我不看性能。该API表示, Integer.valueOf(字符串)是PTED一样的,如果它被传递到除$ P $的Integer.parseInt(字符串) ,只不过它被包装成整数。我想看看你所需要的:一个整数 INT

I would not look at performance. The API says that Integer.valueOf(String) is interpreted the same as if it has been passed to Integer.parseInt(String), except it is wrapped into an Integer. I would look at what you need: an Integer or an int.

Integer.valueOf 返回整数

的Integer.parseInt 返回 INT

这篇关于哪一个是更快? Integer.valueOf(字符串字符串)或的Integer.parseInt(String s)返回?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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