Trust string This class is one of the most frequently used classes in Java, and it's a place for big companies to ask for interviews, and today you'll learn about the string, StringBuilder, and StringBuffer classes, Analyze their similarities and differences and understand the scenarios that each class applies to. The following is a table of contents outline for this article:
A. Do you know the string class?
Two. Deep understanding of String, StringBuffer, StringBuilder
Three. Performance testing of three classes in different scenarios
Four. Common questions about string and stringbuffer (some of the myths circulated on the web that distort string)
If there are any mistakes, please forgive and correct them, I appreciate it.
Please respect the results of the work of the author, reproduced please indicate the reprint address:
Http://www.cnblogs.com/dolphin0520/p/3778589.html one. Do you know the string class?
The best way to understand a class is to look at the implementation source code of the class, where the implementation of the String class
\jdk1.6.0_14\src\java\lang\string.java file.
Opening the class file will reveal that the string class was final decorated:
1 2 3 4 5 6 7 8 9 A (public ) final& nbsp class String implements java.io.Serializable, Comparable<string> charsequence { /** the value is used for character storage. */ PRIVATE&N Bsp final char value[]; |