1.stringutils.join (Object array[],string separator)
Make the array a new string as a symbol or other string interval
Object array[] The array to convert. Separator the interval symbol that makes up a new string, such as "," "|"
private static final string[] str = {"1", "2", "3", "4"};2 String str2 = Stringutils.join (str, "|"); 3 4 System.out.println (STR2);
output Result: 1|2|3|4
Reprinted from: https://www.cnblogs.com/astrocc/archive/2012/10/20/2732733.html
The Spit () method in 2.java
Basic format:stringobj.split ([separator,[limit]]) parameter, where each part,stringobj This represents the string to be split,separator represents the a string or regular expression object that identifies whether one or more characters are used when separating the string. If this option is omitted, a single element array containing the entire string is returned; Limit : Indicates that the value is used to limit the number of elements in the returned array.
This method returns an array of strings, If a special character is encountered, such as a regular expression, for example: | , + , * , ^ , $ , / , | , [ , ] , ( , ) , - , . , \
For example, to use | Vertical bar to split a character, because | itself is a part of the regular expression, so need \ to escape, because the escape using \, and this \ is exactly the character of the regular expression, so you have to use a \, so need two \ \. If you use "." As a separate word, it must be written as follows: String.Split ("\ \"), if the "|" As a separate word, it must be written as follows: String.Split ("\\|"), If there is more than one delimiter in a string, you can use the "|" As a hyphen, for example: "A=1 and b =2 or c=3", the three are separated out, you can use the String.Split ("And|or");
2. String array converted to string
Example:
string[] str = {"abc", "BCD", "def"}; StringBuffer sb = new StringBuffer (); for (int i = 0; i < str.length; i++) {SB append (Str[i]);} String s = sb.tostring ();
If it is a "character array" to "string"
char[] data={' A ', ' B ', ' C '}; String s=new string (data);
Transferred from: https://www.cnblogs.com/SharkBin/p/4512561.html
Conversion of string arrays and strings