The following relationships are found in Java strings by looking at the JDK source code:
The methods in the interface are abstract by default and can be written or not written.
Public interface Charsequence { int length (); char charAt (int index); Charsequence subsequence (int start, int end); Public String toString ();}
The other is the implementation class of the interface and the final class, which cannot be inherited.
Public final class String implements Java.io.Serializable, Comparable<string>, charsequence
<span style= "color: #ff0000;" >StringBuffe</span>
thread safety. However, there is a synchronous object lock, so performance degrades.
Public final class StringBuffer extends Abstractstringbuilder implements Java.io.Serializable, Charsequence
StringBuilder threads are not secure, but are highly efficient in a single-threaded environment.
Public final class StringBuilder extends Abstractstringbuilder implements Java.io.Serializable, Charsequence
Java String Learning Notes