Poison

Time Complexity of Java’s substring()

As of update 6 within Java 7’s lifetime, the behaviour of substring changed to create a copy - so every String refers to a char[] which is not shared with any other object, as far as I’m aware. So at that point, substring() became an O(n) operation where n is the numbers in the substring.

Reference

Time complexity of Java’s substring() - Stack Overflow