问题
How can i put a list of strings, type string
in
String countryList[] = {a};
a is the variable that have the list
so, it will be
String countryList[] = {"heyyesGabon","heyyesGibraltar","heyyesGuinea"}; //and the others
this list comes from console.log in javascript
it always save the last item
回答1:
From List to String array
String [] countryArray = countryList.toArray(new String[0]);
From String array to List
List<String> list = Arrays.asList(array);
回答2:
You can use in-build function list.toArray(stringArray);
it will return String[]
.
String countryList[] = new String[list.size()];
countryList = list.toArray(countryList);
Hope this will help you.
来源:https://stackoverflow.com/questions/60699878/how-can-i-put-a-list-to-array