11

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

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

Manuel Selva
  • 18,554
  • 22
  • 89
  • 134

1 Answers1

16

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.

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

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216