Integer.toString() [英] Integer.toString()

查看:112
本文介绍了Integer.toString()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么 Integer.toString()方法是使用 String.valueOf(int i)而不是使用直接静态方法 Integer.toString(int i) String.valueOf(int i)回调?

Why does the Integer.toString() method is implemented using String.valueOf(int i) instead of using directly static method Integer.toString(int i) which is called back by String.valueOf(int i) ?

更新:我正在使用Sun(现在是Oracle)jdk 1.6.0_12

Update: I am working with a Sun (Oracle now) jdk 1.6.0_12

推荐答案

原因可能是历史性的。 Java 1.0版本的发布是为了尝试满足(被认为是)一个关闭的机会窗口。 API设计中出现了许多错误。但到了Java 1.1时,设计人员意识到修复API中的错误可能会破坏现有程序,并疏远开发人员和用户。因此,他们选择了保留错误(特别是轻微的不一致)。

The reason is probably historical. The Java 1.0 release was made in a hurry to try to meet (what was perceived to be) a closing window of opportunity. Many mistakes were made in the API design. But by the time of Java 1.1, designers realized that fixing mistakes in the API could break existing programs, and alienate developers and users. So they opted for leaving mistakes (especially minor inconsistencies) unfixed.

这只是其中一个轻微的不一致。它在实践中没有任何区别,因为JIT编译器无论如何都会内联调用。

This is just one of those minor inconsistencies. It makes no difference in practice since the JIT compiler will inline the calls anyway.

这篇关于Integer.toString()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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