Write in front:
There are too many things to do, the blog is not very thin. Will write what they think is fun, important places. I hope you will enjoy your discussion and share your ideas. Let the "spark of thought collide" to achieve.
Strings are involved in almost every operation, so strings are especially important.
13.1 Immutable string
The string class seems to modify the string to be worthwhile, in effect creating a completely new string object that contains the modified string content, while the original string object was not moved at all.
13.2 + with StringBuilder
StringBuilder is much faster, if you are interested, you can write two different ways to measure time with + and StringBuilder. You can also configure the environment variable with javap-c ClassName (class name) to see what the JVM bytecode looks like.
It's good to use StringBuilder when there's a loop.
Other than that!
append(/*一个字符串*/);
Don't use something like this.
append(a":" + c);
This way the compiler will push into the trap and create another StringBuilder object for you to handle the string operations in parentheses.
13.3 unconscious recursion
System.out.println("String"this);
Here, the compiler sees a string followed by A +, after which the object is not a string, and the ToString method of this is called. The This.tostring () method may also have this object, so it will continue to be recursive.
13.4 operation on a string
Google for yourself
13.5 Formatting
is a Formater class, for example
System.out.format("%d"x);
It's like C.
13.6 Regular Expressions
A method for efficiently matching strings. Every day will come to share several
13.7 Scan Input
Process the input and analyze the input data.
It's best to use scanner or regular expressions to analyze the scan.
13.8 Split string
StringTokenizer
Because there are two of the above, it has been forgotten = =
Thinking in java---the 13th chapter-string