2021年3月6日星期六

splitting string by comma and space in order to store them into 2 different array

I have below string and I wanted to convert into an array. I want to store all the names into an array and Store the choices that follows the names. For example,

String[] name = {"Home", "Sweet", "Smile, ..."}  

I also want to store their choices as an array:

char[] choice = {'A', 'B', 'C', ...}  

The source String is something like this:

String ls = "Home A,Sweet B,Smile C,Mind D";  

FYI : I know how to split by comma, but I do not know how to get the choices. Any help, I will highly appreciate.

https://stackoverflow.com/questions/66512655/splitting-string-by-comma-and-space-in-order-to-store-them-into-2-different-arra March 07, 2021 at 10:25AM

没有评论:

发表评论