I’ve been wondering about the implementation of charAt function for String/StringBuilder/StringBuffer in java
what is the complexity of that ?
also what about the deleteCharAt() in StringBuffer/StringBuilder ?
I’ve been wondering about the implementation of charAt function for String/StringBuilder/StringBuffer in java what
Share
For
String,StringBuffer, andStringBuilder,charAt()is a constant-time operation.For
StringBufferandStringBuilder,deleteCharAt()is a linear-time operation.StringBufferandStringBuilderhave very similar performance characteristics. The primary difference is that the former issynchronized(so is thread-safe) while the latter is not.