Cross-transfer between string array and string (Join/split)

Source: Internet
Author: User

1, Java1-1. Array of strings = =string: Stringutils:join (object[] array, string separator) Example: Java Code Collection CodeImportorg.apache.commons.lang.StringUtils;  Public classstringutilstrial { Public Static voidMain (string[] args) {//Join all Strings in the Array to a single String,//separated by $#$System.out.println (Stringutils.join (NewString[] {"AB", "CD", "EF"}, "$#$")); }     }         1-2. String = =string array: String:split (String separator) Example: Java Code Collection Code PublicSplitdemo () {String s= "ab$# $CD $# $EF"; //decompose at each space character. string[] ss = S.split ("$#$"); }     2, JavaScript2-1. Array of strings = =string: Array:join (String separator) Example: JS Code Collection Code<mce:script type= "Text/javascript" > <!--var a=NewArray ("A", "B", "C"); A.join ("|");      alert (a); // -</mce:script> 2-2, String = string array: String:split (String separator), String:split (string separator,intlength) Example: JS Code Collection Code<mce:script type= "Text/javascript" > <!--var str= "1234"; var str1= "basketball, volleyball, table tennis"; var arr= Str.split ("");//Split Allvar arr1 = Str1.split (",");//Split by commavar arr2 = Str1.split (",", 2);//two segments are retained according to comma division// -</mce:script>

Cross-transfer between string array and string (Join/split)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.