String method (JDK9)

Disclaimer: The materials used in this column are written by VIP students of Kaige Academy. Students have the right to remain anonymous and have the right to final interpretation of the article. Kaige Academy aims to promote VIP students to learn from each other based on public notes.

String method (JDK9)

Constructor: String#String() No-parameter constructor, the default is an "" empty string String#String(java.lang.String) Gives you a char array, it will help you perform ABCD output

image

GBK Chinese Simplified + Traditional Character Set

GB2312 Chinese Simplified Character Set

As shown below: Give you some traditional characters, which can be displayed according to the default character set, the default is GBK

image

But if you convert the character set to GB2312, those traditional characters will not be displayed, and some garbled characters will appear.

image

How to know the default character set in your system? use

Charset.defaultCharset().displayName()

image

Convert bytes (uniformly returns byte arrays):

image

Other methods:

image

As shown below: Remove left and right spaces and lowercase to uppercase writing

image

Java.lang.String # split (java.lang.String)

Separated by specific characters, regular expressions can be written in the parameters

As shown below: For example, I want to divide 192.168.101 into four parts, how to separate them? is to separate it according to a specific symbol

If it is these 5,564,21341,561,231415,4564,415641,4 with semicolons

Just put a semicolon there.

image

As shown in the figure below: You can also use regular expressions to separate, for example, writing a | line is to separate them one by one

If you encounter 1564561|15451|89754|54646 with these | symbols

To separate them, you need to add \\|

image

indexOf(search) returns -1 is not found

The first two are from the front, the latter two are from the back

image

Locate lookup:

image

As shown below: It is the writing method of finding a single character and finding a string

image

As shown below: It is a positioning search, starting from the 13th

image

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325422835&siteId=291194637