This depends on your specific needs. If it is a delimiter such as "a,b,c"; just divide it directly.
String string = "a,b,c";
String [] stringArr= (","); //Note that the separator needs to be translated...
If it is a string like "abc", it will be
String string = "abc" ;
char [] stringArr = (); //Note that the return value is a char array
If you want to return a byte array, just use the getBytes method directly, it will be OK~~
String string = "abc" ;
byte [] stringArr = ();
At the same time, the front desk can also pass the parameters to the background by splicing. You can write "a, b, c" in this way to convert it into an array form. If splicing it into "["+a+b+"]", you need to do related operations in the background:
Method 1:
String demo = "[a,b,c]"; String demosub = (1,()-1); String demoArray[] = (","); List<String> demoList = (demoArray);
Method 2:
("[a,b,c]").get(0)
Supplementary knowledge:Java converts String-type strings into int-type (or int-type array)
Convert to int array code implementation
String str = "6921168509256"; int[] arr = new int[()]; for (int i = 0; i < (); i++) { arr[i] = ((i, i + 1));//substring is to find the substring that contains the start position, not the end position, and the previous one to the end position } for(int i:arr)//Output array arr (i+" ");
Convert to int-type code implementation
String str = "69211685"; int a = (str); (a);
The above article converts the string type in java into array case is all the content I share with you. I hope you can give you a reference and I hope you support me more.