Conversion of arrays and strings
Looks like the array needs to be a string to fit into the database
So
First, the conversion of arrays and strings in JS
Array variable string var a, B; Two variables an array a a string b
A=new array{0,1,2,3,4,5};
B=a.join ("-"); b= "0-1-2-3-4-5" js inside the array into a string with the array name. Join ("-");
String variable group var b= "0-1-2-3-4-5";
var a=b.split ("-"); In-decomposition js inside the string variable group uses a string. Split ("-");
Second, the use of the list array in Java code
1 Converting a list collection to a list array
List<a> Alist=aservice.getbyid (IDs);//from the database according to the ID of a collection put to the list collection, A is an entity
List<string> blist=new arraylist<string> (); Create a list array to put a number
For (a a1:alist) {
Blist.add (A1.getano ()); Places the number of a in the list collection into List array B. list's. Add Usage
}
2 Converting a list array into a string array
String [] a=new string[blist.size ()]; Creates an array of type string generic collection. Size array. length string. Length ()
Blist.toarray (a);//Convert list array to list array of string array--"string ToArray for Arrays
3 putting a string string into a string array
String s1= "AAAAA";
String s2= "BBBBB";
String s3= "CCCCC";
Arraylist<string> slist=new arraylist<string> (); List array
Slist.add (S1);
Slist.add (S2);
Slist.add (S3);
String [] str=new string[slist.size ()];
Slist.toarray (str);
4 array-"string introduced into the Apache Commons component of the Commons-lang.jar package in the Apache Commons component of the Commons-lang.jar package
String [] a={"abc", "D", "EF"};
String Str=stringutils.join (A, "-"); Stringutils.join next detail
5 Array--"string String.Format () method String.Format () method The next article detailed
String Str=string.format ("%s,%s,%s", a);
6 array-"string traversal stitching StringBuffer stringbuffer inside the Append Method next detail to get
StringBuffer sb=new StringBuffer ();
for (in i=0;i<a.length;i++) {
Sb.append (A[i]);
}
String strn=sb.tostring ();
Conversion of arrays and strings