r/programming • u/Eirenarch • Nov 18 '13
TIL Oracle changed the internal String representation in Java 7 Update 6 increasing the running time of the substring method from constant to N
http://java-performance.info/changes-to-string-java-1-7-0_06/
1.4k
Upvotes
View all comments
Show parent comment
18
u/jaystopher Nov 18 '13
No, String is not just a library class. It is an integral part of the language and specified by the JVM spec. Take a look at how the String constant pool works and how strings are interned. Also consider that the class "Object" has a built in toString method. You wouldn't be able to do this without hacking the JVM.